Initial commit
Plugin/Event API portions inspired/based upon Spout/Flow and FML. Thanks to all those involved Signed-off-by: Chris Sanders <zidane@outlook.com>
This commit is contained in:
commit
5a96c646c0
26 files changed
+1254
No files matched your search
@@ -0,0 +1,17 @@
|
||||
# Normalize as LF in the repository, OS native locally
|
||||
* text=auto
|
||||
*.java text
|
||||
|
||||
# Binary files that should not be modified
|
||||
*.dat binary
|
||||
*.db binary
|
||||
*.icns binary
|
||||
*.ico binary
|
||||
*.jar binary
|
||||
*.jks binary
|
||||
*.jpg binary
|
||||
*.key binary
|
||||
*.png binary
|
||||
*.ttf binary
|
||||
*.wav binary
|
||||
JavaApplicationStub binary
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
# Build #
|
||||
#########
|
||||
MANIFEST.MF
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# Compiled #
|
||||
############
|
||||
bin
|
||||
build
|
||||
dist
|
||||
lib
|
||||
out
|
||||
run
|
||||
target
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
|
||||
# Databases #
|
||||
#############
|
||||
*.db
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# Packages #
|
||||
############
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# Repository #
|
||||
##############
|
||||
.git
|
||||
|
||||
# Logging #
|
||||
###########
|
||||
/logs
|
||||
*.log
|
||||
|
||||
# Misc #
|
||||
########
|
||||
*.bak
|
||||
|
||||
# System #
|
||||
##########
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Project #
|
||||
###########
|
||||
.classpath
|
||||
.externalToolBuilders
|
||||
.gradle
|
||||
.idea
|
||||
.project
|
||||
.settings
|
||||
eclipse
|
||||
nbproject
|
||||
atlassian-ide-plugin.xml
|
||||
build.xml
|
||||
nb-configuration.xml
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
This file is part of ${name}, licensed under the MIT License (MIT).
|
||||
|
||||
Copyright (c) ${year} ${organization} <${url}/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,97 @@
|
||||
// Default tasks
|
||||
defaultTasks 'licenseFormat', 'build', 'install'
|
||||
|
||||
// Apply plugin
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'license'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'signing'
|
||||
|
||||
// Basic project information
|
||||
group = 'org.spongepowered'
|
||||
archivesBaseName = 'spongeapi'
|
||||
version = '1.0.0-SNAPSHOT'
|
||||
|
||||
// Extended project information
|
||||
ext.projectName = 'SpongeAPI'
|
||||
ext.inceptionYear = '2014'
|
||||
ext.packaging = 'jar'
|
||||
ext.url = 'http://spongepowered.org'
|
||||
ext.description = 'SpongeAPI'
|
||||
ext.organization = 'SpongePowered'
|
||||
|
||||
// Define variables
|
||||
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
|
||||
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
|
||||
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
|
||||
|
||||
// Minimum version of Java required
|
||||
sourceCompatibility = '1.6'
|
||||
targetCompatibility = '1.6'
|
||||
|
||||
// Configuration settings
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' // Always check for new snapshots
|
||||
}
|
||||
|
||||
// Gradle repositories and dependencies
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
|
||||
}
|
||||
}
|
||||
|
||||
// Project repositories
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'sonatype-nexus-public'
|
||||
url = 'https://oss.sonatype.org/content/repositories/public/'
|
||||
}
|
||||
}
|
||||
|
||||
// Project dependencies
|
||||
dependencies {
|
||||
compile 'org.apache.logging.log4j:log4j-api:2.0.2'
|
||||
}
|
||||
|
||||
// Filter, process, and include resources
|
||||
processResources {
|
||||
// Include in final JAR
|
||||
from(rootProject.rootDir) {
|
||||
include 'LICENSE.txt'
|
||||
}
|
||||
}
|
||||
|
||||
license {
|
||||
ext.name = project.name
|
||||
ext.organization = organization
|
||||
ext.url = url
|
||||
ext.year = inceptionYear
|
||||
header rootProject.file('HEADER.txt')
|
||||
ignoreFailures true
|
||||
strictCheck true
|
||||
}
|
||||
|
||||
// Source compiler configuration
|
||||
configure([compileJava, compileTestJava]) {
|
||||
options.compilerArgs << '-Xlint:all'
|
||||
options.compilerArgs << '-Xlint:-path'
|
||||
options.deprecation = true
|
||||
}
|
||||
|
||||
// JAR manifest configuration
|
||||
jar.manifest.mainAttributes(
|
||||
"Built-By": System.properties['user.name'],
|
||||
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
|
||||
"Implementation-Title": name,
|
||||
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
|
||||
"Implementation-Vendor": url)
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
#Sat May 03 12:44:05 CDT 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-all.zip
|
||||
@@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || 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
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
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
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
Vendored
+90
@@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@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=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_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=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%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
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.spongepowered.example;
|
||||
|
||||
import org.spongepowered.api.event.SpongeEventHandler;
|
||||
import org.spongepowered.api.event.state.SpongeInitializedEvent;
|
||||
import org.spongepowered.api.event.state.SpongeServerStartingEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
|
||||
@Plugin(id = "ExamplePlugin", name = "Example")
|
||||
public class ExamplePlugin {
|
||||
@SpongeEventHandler
|
||||
public void onInitialized(SpongeInitializedEvent event) {
|
||||
event.game.getLogger().info("Hey folks, I'm initialized!");
|
||||
}
|
||||
|
||||
@SpongeEventHandler
|
||||
public void onServerStarting(SpongeServerStartingEvent event) {
|
||||
event.game.getLogger().info("Hey...my implementation's server is starting?");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.api.event.EventManager;
|
||||
import org.spongepowered.api.plugin.PluginManager;
|
||||
|
||||
/**
|
||||
* The core accessor of the API. The implementation uses this to pass constructed objects.
|
||||
*/
|
||||
public interface Game {
|
||||
/**
|
||||
* Gets the {@link org.apache.logging.log4j.Logger} of the implementation.
|
||||
*
|
||||
* @return The logger
|
||||
*/
|
||||
public Logger getLogger();
|
||||
|
||||
/**
|
||||
* Returns the {@link org.spongepowered.api.Platform} the implementation is executing from.
|
||||
*
|
||||
* @return The platform
|
||||
*/
|
||||
public Platform getPlatform();
|
||||
|
||||
/**
|
||||
* Gets the {@link org.spongepowered.api.plugin.PluginManager}.
|
||||
*
|
||||
* @return The plugin manager
|
||||
*/
|
||||
public PluginManager getPluginManager();
|
||||
|
||||
/**
|
||||
* Gets the {@link org.spongepowered.api.event.EventManager}.
|
||||
*
|
||||
* @return The event manager
|
||||
*/
|
||||
public EventManager getEventManager();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api;
|
||||
|
||||
/**
|
||||
* TODO Need to match this closely to FML's lifecycle
|
||||
*/
|
||||
public enum GameState {
|
||||
DISABLED, DISABLING, ENABLED, ENABLING, INITIALIZED, SERVER_STARTING
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api;
|
||||
|
||||
public enum Platform {
|
||||
CLIENT, SERVER
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event;
|
||||
|
||||
public interface EventManager {
|
||||
/**
|
||||
* Registers an object to receive {@link org.spongepowered.api.event.SpongeEvent}s.
|
||||
*
|
||||
* @param obj The object
|
||||
*/
|
||||
public void register(Object obj);
|
||||
|
||||
/**
|
||||
* Un-registers an object from receiving {@link org.spongepowered.api.event.SpongeEvent}s.
|
||||
*
|
||||
* @param obj The object
|
||||
*/
|
||||
public void unregister(Object obj);
|
||||
|
||||
/**
|
||||
* Fires an {@link org.spongepowered.api.event.SpongeEvent} to all objects that handle it.
|
||||
*
|
||||
* @param event The event
|
||||
* @return True if canceled, false if not
|
||||
*/
|
||||
public boolean fire(SpongeEvent event);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event;
|
||||
|
||||
/**
|
||||
* Order that a {@link org.spongepowered.api.event.SpongeEventHandler} may be registered at.
|
||||
*/
|
||||
public enum Order {
|
||||
/**
|
||||
* Called before all other handlers. Should be used for high-priority event cancelling. Should not be used to make changes to any implementation core objects.
|
||||
*/
|
||||
PRE(0, false),
|
||||
/**
|
||||
* Called after "Pre". Should be used for high-priority event cancelling.
|
||||
*/
|
||||
FIRST(1, false),
|
||||
/**
|
||||
* Called after "First" handlers and before "Early" handlers.<br> Is called even when event has been cancelled.<br> Should generally be used to un-cancel events cancelled in First.<br>
|
||||
*/
|
||||
FIRST_IGNORE_CANCELLED(2, true),
|
||||
/**
|
||||
* Called after "First" handlers. Should generally be used for low priority event cancelling.
|
||||
*/
|
||||
EARLY(3, false),
|
||||
/**
|
||||
* Called after "Early" handlers and before "Default" handlers.<br> Called even when event has been cancelled.<br> This is for general-purpose always-run events.<br>
|
||||
*/
|
||||
EARLY_IGNORE_CANCELLED(4, true),
|
||||
/**
|
||||
* Default call, for general purpose handlers.
|
||||
*/
|
||||
DEFAULT(5, false),
|
||||
/**
|
||||
* Called after "Default" handlers and before "Late" handlers.<br> Called even when the event has been canceled.<br> This is for general-purpose always-run events.<br>
|
||||
*/
|
||||
DEFAULT_IGNORE_CANCELLED(6, true),
|
||||
/**
|
||||
* Called after "Default" handlers.
|
||||
*/
|
||||
LATE(7, false),
|
||||
/**
|
||||
* Called after "Late" handlers and before "Last" handlers.<br> Called even when the event has been cancelled.<br>
|
||||
*/
|
||||
LATE_IGNORE_CANCELLED(8, true),
|
||||
/**
|
||||
* Called after "Late" handlers.<br> No changes to the event should be made in this order slot (may be enforced by implementation).<br>
|
||||
*/
|
||||
LAST(9, false),
|
||||
/**
|
||||
* Called after "Last" handlers and before "Post" handlers.<br> No changes to the event should be made in this order slot (may be enforced by implementation).<br> This is called even when event has been cancelled.<br>
|
||||
*/
|
||||
LAST_IGNORE_CANCELLED(10, true),
|
||||
/**
|
||||
* Called after all other handlers. Should not be used to make changes to the event or any implementation core objects.
|
||||
*/
|
||||
POST(11, false);
|
||||
|
||||
private final int index;
|
||||
private final boolean ignoreCancelled;
|
||||
|
||||
Order(int index, boolean ignoreCancelled) {
|
||||
this.index = index;
|
||||
this.ignoreCancelled = ignoreCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the index
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this Order ignores cancellation status
|
||||
*/
|
||||
public boolean ignoresCancelled() {
|
||||
return ignoreCancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event;
|
||||
|
||||
public enum Result {
|
||||
DENY, DEFAULT, ALLOW, NO_RESULT
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event;
|
||||
|
||||
import org.spongepowered.api.Game;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
public abstract class SpongeEvent {
|
||||
private static final Map<Class<?>, Map<Class<?>, Boolean>> annotationMap = new ConcurrentHashMap<Class<?>, Map<Class<?>, Boolean>>();
|
||||
public final Game game;
|
||||
private final boolean isCancellable;
|
||||
private boolean isCancelled;
|
||||
public SpongeEvent(Game game) {
|
||||
this.game = game;
|
||||
isCancellable = hasAnnotation(Cancellable.class);
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return Result.NO_RESULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this event can be cancelled.
|
||||
*
|
||||
* @return True if cancelled is allowed, false if not
|
||||
*/
|
||||
public boolean isCancellable() {
|
||||
return isCancellable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this event has been cancelled.
|
||||
*
|
||||
* @return True if cancelled, false if not
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this event as cancelled.
|
||||
*
|
||||
* @param cancel True to cancel, false to not cancel
|
||||
* @throws java.lang.IllegalArgumentException If an attempt is made to cancel but the event is not cancellable
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
if (!isCancellable()) {
|
||||
throw new IllegalArgumentException("Attempted to cancel an event that is not cancellable!");
|
||||
}
|
||||
isCancelled = cancel;
|
||||
}
|
||||
|
||||
private boolean hasAnnotation(Class<? extends Annotation> annotation) {
|
||||
Class<?> me = this.getClass();
|
||||
Map<Class<?>, Boolean> list = annotationMap.get(me);
|
||||
if (list == null) {
|
||||
list = new ConcurrentHashMap<Class<?>, Boolean>();
|
||||
annotationMap.put(me, list);
|
||||
}
|
||||
|
||||
Boolean cached = list.get(annotation);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
Class<?> cls = me;
|
||||
while (cls != SpongeEvent.class) {
|
||||
if (cls.isAnnotationPresent(annotation)) {
|
||||
list.put(annotation, true);
|
||||
return true;
|
||||
}
|
||||
cls = cls.getSuperclass();
|
||||
}
|
||||
|
||||
list.put(annotation, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Retention(value = RUNTIME)
|
||||
@Target(value = TYPE)
|
||||
public @interface Cancellable {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Retention(value = RUNTIME)
|
||||
@Target(value = METHOD)
|
||||
public @interface SpongeEventHandler {
|
||||
public Order order() default Order.DEFAULT;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event.state;
|
||||
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameState;
|
||||
|
||||
public class SpongeInitializedEvent extends SpongeStateEvent {
|
||||
public SpongeInitializedEvent(Game game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameState getState() {
|
||||
return GameState.INITIALIZED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event.state;
|
||||
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameState;
|
||||
|
||||
public class SpongeServerStartingEvent extends SpongeStateEvent {
|
||||
public SpongeServerStartingEvent(Game game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameState getState() {
|
||||
return GameState.SERVER_STARTING;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event.state;
|
||||
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameState;
|
||||
import org.spongepowered.api.event.SpongeEvent;
|
||||
|
||||
public abstract class SpongeStateEvent extends SpongeEvent {
|
||||
public SpongeStateEvent(Game game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isCancellable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract GameState getState();
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.plugin;
|
||||
|
||||
/**
|
||||
* Thrown by the implementation if it determines that a {@link org.spongepowered.api.plugin.Plugin} being loaded is invalid.
|
||||
*/
|
||||
public class InvalidPluginException extends Exception {
|
||||
private static final long serialVersionUID = 15816838168L;
|
||||
|
||||
public InvalidPluginException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidPluginException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.plugin;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Plugin {
|
||||
String id();
|
||||
String name();
|
||||
String version() default "unknown";
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.plugin;
|
||||
|
||||
public interface PluginContainer {
|
||||
/**
|
||||
* Gets the id of the {@link org.spongepowered.api.plugin.Plugin} within this container.
|
||||
* @return The id
|
||||
*/
|
||||
public String getID();
|
||||
|
||||
/**
|
||||
* Gets the name of the {@link org.spongepowered.api.plugin.Plugin} within this container.
|
||||
* @return The name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Gets the version of the {@link org.spongepowered.api.plugin.Plugin} within this container.
|
||||
* @return The name
|
||||
*/
|
||||
public String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the created instance of {@link org.spongepowered.api.plugin.Plugin}
|
||||
*
|
||||
* TODO Provide a way to not dereference this back to Object
|
||||
* @return The instance
|
||||
*/
|
||||
public Object getInstance();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.plugin;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface PluginManager {
|
||||
/**
|
||||
* Retrieves a {@link org.spongepowered.api.plugin.PluginContainer} based on its name.
|
||||
*
|
||||
* @param name The name
|
||||
* @return The plugin or null if not found
|
||||
*/
|
||||
public PluginContainer getPlugin(String name);
|
||||
|
||||
/**
|
||||
* Gets the {@link org.apache.logging.log4j.Logger} for the {@link org.spongepowered.api.plugin.PluginContainer}.
|
||||
*
|
||||
* @param plugin The plugin
|
||||
* @return The logger
|
||||
*/
|
||||
public Logger getLogger(PluginContainer plugin);
|
||||
|
||||
/**
|
||||
* Gets a {@link java.util.Collection} of all {@link org.spongepowered.api.plugin.PluginContainer}s
|
||||
*
|
||||
* @return The plugins
|
||||
*/
|
||||
public Collection<PluginContainer> getPlugins();
|
||||
}
|
||||
Reference in new issue
Block a user