mirror of
https://github.com/PryPurity/WorldBorder.git
synced 2024-11-25 12:05:15 +01:00
Initial commit, version 0.9
This commit is contained in:
commit
54b8a000a4
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
||||
WorldBorder
|
||||
===========
|
||||
|
||||
A Bukkit plugin to provide borders for your worlds, to limit their sizes.
|
74
build.xml
Normal file
74
build.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="WorldBorder" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project WorldBorder.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="WorldBorder-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
Binary file not shown.
BIN
lib/junit/junit-3.8.2-api.zip
Normal file
BIN
lib/junit/junit-3.8.2-api.zip
Normal file
Binary file not shown.
BIN
lib/junit/junit-3.8.2.jar
Normal file
BIN
lib/junit/junit-3.8.2.jar
Normal file
Binary file not shown.
BIN
lib/junit_4/junit-4.5-api.zip
Normal file
BIN
lib/junit_4/junit-4.5-api.zip
Normal file
Binary file not shown.
BIN
lib/junit_4/junit-4.5-src.jar
Normal file
BIN
lib/junit_4/junit-4.5-src.jar
Normal file
Binary file not shown.
BIN
lib/junit_4/junit-4.5.jar
Normal file
BIN
lib/junit_4/junit-4.5.jar
Normal file
Binary file not shown.
12
lib/nblibraries.properties
Normal file
12
lib/nblibraries.properties
Normal file
@ -0,0 +1,12 @@
|
||||
libs.CopyLibs.classpath=\
|
||||
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
|
||||
libs.junit.classpath=\
|
||||
${base}/junit/junit-3.8.2.jar
|
||||
libs.junit.javadoc=\
|
||||
${base}/junit/junit-3.8.2-api.zip
|
||||
libs.junit_4.classpath=\
|
||||
${base}/junit_4/junit-4.5.jar
|
||||
libs.junit_4.javadoc=\
|
||||
${base}/junit_4/junit-4.5-api.zip
|
||||
libs.junit_4.src=\
|
||||
${base}/junit_4/junit-4.5-src.jar
|
3
manifest.mf
Normal file
3
manifest.mf
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
908
nbproject/build-impl.xml
Normal file
908
nbproject/build-impl.xml
Normal file
@ -0,0 +1,908 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="WorldBorder-impl">
|
||||
<fail message="Please build using Ant 1.7.1 or higher.">
|
||||
<condition>
|
||||
<not>
|
||||
<antversion atleast="1.7.1"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="-pre-init" name="-init-private">
|
||||
<property file="nbproject/private/config.properties"/>
|
||||
<property file="nbproject/private/configs/${config}.properties"/>
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-pre-init-libraries">
|
||||
<property location="lib\nblibraries.properties" name="libraries.path"/>
|
||||
<dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
|
||||
<pathconvert dirsep="/" property="libraries.dir">
|
||||
<path path="${libraries.dir.nativedirsep}"/>
|
||||
</pathconvert>
|
||||
<basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
|
||||
<available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
|
||||
</target>
|
||||
<target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
|
||||
<loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
|
||||
<filterchain>
|
||||
<replacestring from="$${base}" to="${libraries.dir}"/>
|
||||
<escapeunicode/>
|
||||
</filterchain>
|
||||
</loadproperties>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
|
||||
<loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
|
||||
<filterchain>
|
||||
<replacestring from="$${base}" to="${libraries.dir}"/>
|
||||
<escapeunicode/>
|
||||
</filterchain>
|
||||
</loadproperties>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
|
||||
<property file="nbproject/configs/${config}.properties"/>
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<available file="${application.splash}" property="splashscreen.available"/>
|
||||
<condition property="main.class.available">
|
||||
<and>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class.available"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="do.mkdist">
|
||||
<and>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
<not>
|
||||
<istrue value="${mkdist.disabled}"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="do.mkdist"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class+mkdist.available}"/>
|
||||
<istrue value="${splashscreen.available}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="do.archive">
|
||||
<not>
|
||||
<istrue value="${jar.archive.disabled}"/>
|
||||
</not>
|
||||
</condition>
|
||||
<condition property="do.archive+manifest.available">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<istrue value="${do.archive}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="do.archive+manifest.available+main.class">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<istrue value="${do.archive}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="do.archive+manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class+mkdist.available}"/>
|
||||
<istrue value="${do.archive}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class+mkdist.available+splashscreen.available}"/>
|
||||
<istrue value="${do.archive}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or/>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<and>
|
||||
<isset property="javadoc.preview"/>
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
<property name="application.args" value=""/>
|
||||
<property name="source.encoding" value="${file.encoding}"/>
|
||||
<property name="runtime.encoding" value="${source.encoding}"/>
|
||||
<condition property="javadoc.encoding.used" value="${javadoc.encoding}">
|
||||
<and>
|
||||
<isset property="javadoc.encoding"/>
|
||||
<not>
|
||||
<equals arg1="${javadoc.encoding}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javadoc.encoding.used" value="${source.encoding}"/>
|
||||
<property name="includes" value="**"/>
|
||||
<property name="excludes" value=""/>
|
||||
<property name="do.depend" value="false"/>
|
||||
<condition property="do.depend.true">
|
||||
<istrue value="${do.depend}"/>
|
||||
</condition>
|
||||
<path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
|
||||
<condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
|
||||
<length length="0" string="${endorsed.classpath}" when="greater"/>
|
||||
</condition>
|
||||
<property name="javac.fork" value="false"/>
|
||||
<property name="jar.index" value="false"/>
|
||||
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
|
||||
<fail unless="src.src.dir">Must set src.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${src.src.dir}" name="srcdir"/>
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<attribute default="${javac.classpath}" name="classpath"/>
|
||||
<attribute default="${javac.processorpath}" name="processorpath"/>
|
||||
<attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="${javac.debug}" name="debug"/>
|
||||
<attribute default="${empty.dir}" name="sourcepath"/>
|
||||
<attribute default="${empty.dir}" name="gensrcdir"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property location="${build.dir}/empty" name="empty.dir"/>
|
||||
<mkdir dir="${empty.dir}"/>
|
||||
<mkdir dir="@{apgeneratedsrcdir}"/>
|
||||
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
|
||||
<src>
|
||||
<dirset dir="@{gensrcdir}" erroronmissingdir="false">
|
||||
<include name="*"/>
|
||||
</dirset>
|
||||
</src>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<compilerarg value="-processorpath"/>
|
||||
<compilerarg path="@{processorpath}:${empty.dir}"/>
|
||||
<compilerarg line="${ap.processors.internal}"/>
|
||||
<compilerarg line="${annotation.processing.processor.options}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="@{apgeneratedsrcdir}"/>
|
||||
<compilerarg line="${ap.proc.none.internal}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${src.src.dir}" name="srcdir"/>
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<attribute default="${javac.classpath}" name="classpath"/>
|
||||
<attribute default="${javac.processorpath}" name="processorpath"/>
|
||||
<attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="${javac.debug}" name="debug"/>
|
||||
<attribute default="${empty.dir}" name="sourcepath"/>
|
||||
<attribute default="${empty.dir}" name="gensrcdir"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property location="${build.dir}/empty" name="empty.dir"/>
|
||||
<mkdir dir="${empty.dir}"/>
|
||||
<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
|
||||
<src>
|
||||
<dirset dir="@{gensrcdir}" erroronmissingdir="false">
|
||||
<include name="*"/>
|
||||
</dirset>
|
||||
</src>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
|
||||
<macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${src.src.dir}" name="srcdir"/>
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<attribute default="${javac.classpath}" name="classpath"/>
|
||||
<sequential>
|
||||
<depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</depend>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<sequential>
|
||||
<fail unless="javac.includes">Must set javac.includes</fail>
|
||||
<pathconvert pathsep="${line.separator}" property="javac.includes.binary">
|
||||
<path>
|
||||
<filelist dir="@{destdir}" files="${javac.includes}"/>
|
||||
</path>
|
||||
<globmapper from="*.java" to="*.class"/>
|
||||
</pathconvert>
|
||||
<tempfile deleteonexit="true" property="javac.includesfile.binary"/>
|
||||
<echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
|
||||
<delete>
|
||||
<files includesfile="${javac.includesfile.binary}"/>
|
||||
</delete>
|
||||
<delete file="${javac.includesfile.binary}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<sequential>
|
||||
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
|
||||
<batchtest todir="${build.test.results.dir}"/>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-debug-args" name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute default="${main.class}" name="name"/>
|
||||
<attribute default="${debug.classpath}" name="classpath"/>
|
||||
<attribute default="" name="stopclassname"/>
|
||||
<sequential>
|
||||
<nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute default="${build.classes.dir}" name="dir"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset dir="@{dir}" includes="${fix.classes}">
|
||||
<include name="${fix.includes}*.class"/>
|
||||
</fileset>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-debug-args">
|
||||
<property name="version-output" value="java version "${ant.java.version}"/>
|
||||
<condition property="have-jdk-older-than-1.4">
|
||||
<or>
|
||||
<contains string="${version-output}" substring="java version "1.0"/>
|
||||
<contains string="${version-output}" substring="java version "1.1"/>
|
||||
<contains string="${version-output}" substring="java version "1.2"/>
|
||||
<contains string="${version-output}" substring="java version "1.3"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
|
||||
<istrue value="${have-jdk-older-than-1.4}"/>
|
||||
</condition>
|
||||
<condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
|
||||
<isset property="debug.transport"/>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-init-debug-args" name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${main.class}" name="classname"/>
|
||||
<attribute default="${debug.classpath}" name="classpath"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java classname="@{classname}" dir="${work.dir}" fork="true">
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg line="${debug-args-line}"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
|
||||
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
|
||||
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper from="run-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute default="${main.class}" name="classname"/>
|
||||
<attribute default="${run.classpath}" name="classpath"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java classname="@{classname}" dir="${work.dir}" fork="true">
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
|
||||
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper from="run-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-copylibs">
|
||||
<macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert pathsep=" " property="jar.classpath">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
|
||||
<copylibs compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
<customize/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="-init-ap-cmdline-properties">
|
||||
<property name="annotation.processing.enabled" value="true"/>
|
||||
<property name="annotation.processing.processors.list" value=""/>
|
||||
<property name="annotation.processing.processor.options" value=""/>
|
||||
<property name="annotation.processing.run.all.processors" value="true"/>
|
||||
<property name="javac.processorpath" value="${javac.classpath}"/>
|
||||
<property name="javac.test.processorpath" value="${javac.test.classpath}"/>
|
||||
<condition property="ap.supported.internal" value="true">
|
||||
<not>
|
||||
<matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
|
||||
</not>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
|
||||
<condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
|
||||
<isfalse value="${annotation.processing.run.all.processors}"/>
|
||||
</condition>
|
||||
<condition else="" property="ap.proc.none.internal" value="-proc:none">
|
||||
<isfalse value="${annotation.processing.enabled}"/>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
|
||||
<property name="ap.cmd.line.internal" value=""/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="-deps-jar-init" unless="built-jar.properties">
|
||||
<property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
|
||||
<delete file="${built-jar.properties}" quiet="true"/>
|
||||
</target>
|
||||
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
|
||||
<echo level="warn" message="Cycle detected: WorldBorder was already built"/>
|
||||
</target>
|
||||
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<touch file="${built-jar.properties}" verbose="false"/>
|
||||
<property file="${built-jar.properties}" prefix="already.built.jar."/>
|
||||
<antcall target="-warn-already-built-jar"/>
|
||||
<propertyfile file="${built-jar.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</propertyfile>
|
||||
</target>
|
||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||
<target depends="init" name="-check-automatic-build">
|
||||
<available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
|
||||
</target>
|
||||
<target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
|
||||
<antcall target="clean"/>
|
||||
</target>
|
||||
<target depends="init,deps-jar" name="-pre-pre-compile">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target if="do.depend.true" name="-compile-depend">
|
||||
<pathconvert property="build.generated.subdirs">
|
||||
<dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="*"/>
|
||||
</dirset>
|
||||
</pathconvert>
|
||||
<j2seproject3:depend srcdir="${src.src.dir}:${build.generated.subdirs}"/>
|
||||
</target>
|
||||
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
|
||||
<j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target if="has.persistence.xml" name="-copy-persistence-xml">
|
||||
<mkdir dir="${build.classes.dir}/META-INF"/>
|
||||
<copy todir="${build.classes.dir}/META-INF">
|
||||
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:force-recompile/>
|
||||
<j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.src.dir}"/>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target depends="init" name="-pre-pre-jar">
|
||||
<dirname file="${dist.jar}" property="dist.jar.dir"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
|
||||
<property location="${dist.jar}" name="dist.jar.resolved"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen">
|
||||
<basename file="${application.splash}" property="splashscreen.basename"/>
|
||||
<mkdir dir="${build.classes.dir}/META-INF"/>
|
||||
<copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
|
||||
<j2seproject3:copylibs>
|
||||
<customize>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
|
||||
</customize>
|
||||
</j2seproject3:copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property location="${dist.jar}" name="dist.jar.resolved"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available">
|
||||
<j2seproject3:copylibs>
|
||||
<customize>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property location="${dist.jar}" name="dist.jar.resolved"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries-and-splashscreen,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target depends="init,compile" description="Run a main class." name="run">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="-do-not-recompile">
|
||||
<property name="javac.includes.binary" value=""/>
|
||||
</target>
|
||||
<target depends="init,compile-single" name="run-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single" name="run-test-with-main">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target depends="init" if="netbeans.home" name="-debug-start-debugger">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
|
||||
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile" name="-debug-start-debuggee">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
|
||||
<target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
|
||||
<target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
|
||||
<target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
|
||||
<target depends="init" name="-pre-debug-fix">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
</fileset>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
<fileset dir="${src.src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<filename name="**/doc-files/**"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/doc-files/**"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
<target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target if="do.depend.true" name="-compile-test-depend">
|
||||
<j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir=""/>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
|
||||
<j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir=""/>
|
||||
<copy todir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
|
||||
<j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="" srcdir=""/>
|
||||
<copy todir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init" if="have.tests" name="-pre-test-run">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
|
||||
<j2seproject3:junit testincludes="**/*Test.java"/>
|
||||
</target>
|
||||
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
|
||||
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target depends="init" if="have.tests" name="test-report"/>
|
||||
<target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
|
||||
<target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
|
||||
<target depends="init" if="have.tests" name="-pre-test-run-single">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit excludes="" includes="${test.includes}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
|
||||
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
|
||||
<delete file="${test.report.file}"/>
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
<j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
|
||||
<customize>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<arg value="${test.class}"/>
|
||||
<arg value="showoutput=true"/>
|
||||
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
|
||||
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
|
||||
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
|
||||
<target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="init,compile-single" name="run-applet">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-deps-clean-init" unless="built-clean.properties">
|
||||
<property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
|
||||
<delete file="${built-clean.properties}" quiet="true"/>
|
||||
</target>
|
||||
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
|
||||
<echo level="warn" message="Cycle detected: WorldBorder was already built"/>
|
||||
</target>
|
||||
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<touch file="${built-clean.properties}" verbose="false"/>
|
||||
<property file="${built-clean.properties}" prefix="already.built.clean."/>
|
||||
<antcall target="-warn-already-built-clean"/>
|
||||
<propertyfile file="${built-clean.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</propertyfile>
|
||||
</target>
|
||||
<target depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
|
||||
<target name="-check-call-dep">
|
||||
<property file="${call.built.properties}" prefix="already.built."/>
|
||||
<condition property="should.call.dep">
|
||||
<not>
|
||||
<isset property="already.built.${call.subproject}"/>
|
||||
</not>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
|
||||
<ant antfile="${call.script}" inheritall="false" target="${call.target}">
|
||||
<propertyset>
|
||||
<propertyref prefix="transfer."/>
|
||||
<mapper from="transfer.*" to="*" type="glob"/>
|
||||
</propertyset>
|
||||
</ant>
|
||||
</target>
|
||||
</project>
|
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=7ce24f55
|
||||
build.xml.script.CRC32=cc9e7e41
|
||||
build.xml.stylesheet.CRC32=28e38971@1.38.3.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=7ce24f55
|
||||
nbproject/build-impl.xml.script.CRC32=cf0abb2c
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45
|
0
nbproject/private/config.properties
Normal file
0
nbproject/private/config.properties
Normal file
7
nbproject/private/private.properties
Normal file
7
nbproject/private/private.properties
Normal file
@ -0,0 +1,7 @@
|
||||
compile.on.save=true
|
||||
do.depend=false
|
||||
do.jar=true
|
||||
file.reference.CalcTest-src=C:\\Users\\Brett Flannigan\\Documents\\svn\\WorldBorder\\src
|
||||
javac.debug=true
|
||||
javadoc.preview=true
|
||||
user.properties.file=C:\\Users\\Brett Flannigan\\.netbeans\\6.9\\build.properties
|
4
nbproject/private/private.xml
Normal file
4
nbproject/private/private.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
</project-private>
|
77
nbproject/project.properties
Normal file
77
nbproject/project.properties
Normal file
@ -0,0 +1,77 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=WorldBorder
|
||||
application.vendor=Brett Flannigan
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
# Uncomment to specify the preferred debugger connection transport:
|
||||
#debug.transport=dt_socket
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/WorldBorder.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.CalcTest-src=src
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=lib/craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
file.reference.Permissions.jar=lib/Permissions.jar
|
||||
includes=**
|
||||
jar.compress=true
|
||||
javac.classpath=\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.Permissions.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}:\
|
||||
${libs.junit_4.classpath}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=ISO-8859-1
|
||||
src.src.dir=src
|
16
nbproject/project.xml
Normal file
16
nbproject/project.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>WorldBorder</name>
|
||||
<source-roots>
|
||||
<root id="src.src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots/>
|
||||
</data>
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>lib\nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
</configuration>
|
||||
</project>
|
177
src/com/wimbli/WorldBorder/BorderData.java
Normal file
177
src/com/wimbli/WorldBorder/BorderData.java
Normal file
@ -0,0 +1,177 @@
|
||||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class BorderData {
|
||||
// the main data interacted with
|
||||
private double x = 0;
|
||||
private double z = 0;
|
||||
private int radius = 0;
|
||||
|
||||
// some extra data kept handy for faster border checks
|
||||
private double maxX;
|
||||
private double minX;
|
||||
private double maxZ;
|
||||
private double minZ;
|
||||
private int radiusSquared;
|
||||
private double DefiniteSquare;
|
||||
|
||||
public BorderData(double x, double z, int radius)
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.radius = radius;
|
||||
this.maxX = x + radius;
|
||||
this.minX = x - radius;
|
||||
this.maxZ = z + radius;
|
||||
this.minZ = z - radius;
|
||||
this.radiusSquared = radius * radius;
|
||||
this.DefiniteSquare = Math.sqrt(.5 * this.radiusSquared);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
public void setX(double x)
|
||||
{
|
||||
this.x = x;
|
||||
this.maxX = x + radius;
|
||||
this.minX = x - radius;
|
||||
}
|
||||
public double getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
public void setZ(double z)
|
||||
{
|
||||
this.z = z;
|
||||
this.maxZ = z + radius;
|
||||
this.minZ = z - radius;
|
||||
}
|
||||
public int getRadius()
|
||||
{
|
||||
return radius;
|
||||
}
|
||||
public void setRadius(int radius)
|
||||
{
|
||||
this.radius = radius;
|
||||
this.maxX = x + radius;
|
||||
this.minX = x - radius;
|
||||
this.maxZ = z + radius;
|
||||
this.minZ = z - radius;
|
||||
this.radiusSquared = radius * radius;
|
||||
this.DefiniteSquare = Math.sqrt(.5 * this.radiusSquared);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "radius " + radius + " at X: " + Config.coord.format(x) + " Z: " + Config.coord.format(z);
|
||||
}
|
||||
|
||||
// This algorithm of course needs to be fast, since it will be run very frequently
|
||||
public boolean insideBorder(double xLoc, double zLoc, boolean round)
|
||||
{
|
||||
if (!round) // square border
|
||||
return (xLoc > minX && xLoc < maxX && zLoc > minZ && zLoc < maxZ);
|
||||
else // round border
|
||||
{
|
||||
// round border checking algorithm is from rBorder by Reil with almost no changes, thanks
|
||||
double X = Math.abs(x - xLoc);
|
||||
double Z = Math.abs(z - zLoc);
|
||||
|
||||
if (X < DefiniteSquare && Z < DefiniteSquare)
|
||||
return true; // Definitely inside
|
||||
else if (X >= radius || Z >= radius)
|
||||
return false; // Definitely outside
|
||||
else if (X * X + Z * Z < radiusSquared)
|
||||
return true; // After much calculation, inside
|
||||
else
|
||||
return false; // Apparently outside, then
|
||||
}
|
||||
}
|
||||
|
||||
public Location correctedPosition(Location loc, boolean round)
|
||||
{
|
||||
double xLoc = loc.getX();
|
||||
double zLoc = loc.getZ();
|
||||
double yLoc = loc.getY();
|
||||
|
||||
if (!round) // square border
|
||||
{
|
||||
if (xLoc <= minX)
|
||||
xLoc = minX + 3;
|
||||
else if (xLoc >= maxX)
|
||||
xLoc = maxX - 3;
|
||||
if (zLoc <= minZ)
|
||||
zLoc = minZ + 3;
|
||||
else if (zLoc >= maxZ)
|
||||
zLoc = maxZ - 3;
|
||||
}
|
||||
else // round border
|
||||
{
|
||||
// algorithm from: http://stackoverflow.com/questions/300871/best-way-to-find-a-point-on-a-circle-closest-to-a-given-point
|
||||
double vX = xLoc - x;
|
||||
double vZ = zLoc - z;
|
||||
double magV = Math.sqrt(vX*vX + vZ*vZ);
|
||||
xLoc = x + vX / magV * (radius - 3);
|
||||
zLoc = z + vZ / magV * (radius - 3);
|
||||
}
|
||||
|
||||
yLoc = getSafeY(loc.getWorld(), Location.locToBlock(xLoc), Location.locToBlock(yLoc), Location.locToBlock(zLoc));
|
||||
if (yLoc == -1)
|
||||
return null;
|
||||
|
||||
return new Location(loc.getWorld(), Math.floor(xLoc) + 0.5, yLoc, Math.floor(zLoc) + 0.5, loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
//these material IDs are acceptable for places to teleport player; breathable blocks and water
|
||||
private static Set<Integer> acceptableBlocks = new HashSet<Integer>(Arrays.asList(
|
||||
new Integer[] {0, 6, 8, 9, 37, 38, 39, 40, 50, 55, 59, 63, 64, 65, 66, 68, 69, 70, 71, 72, 75, 76, 77, 83, 93, 94}
|
||||
));
|
||||
|
||||
//these material IDs are ones we don't want to drop the player onto
|
||||
private static Set<Integer> painfulBlocks = new HashSet<Integer>(Arrays.asList(
|
||||
new Integer[] {10, 11, 81}
|
||||
));
|
||||
|
||||
// check if a particular spot consists of 2 breathable blocks over something relatively solid
|
||||
private boolean isSafeSpot(World world, int X, int Y, int Z)
|
||||
{
|
||||
Integer below = (Integer)world.getBlockAt(X, Y - 1, Z).getTypeId();
|
||||
return (acceptableBlocks.contains((Integer)world.getBlockAt(X, Y, Z).getTypeId()) // target block breatheable
|
||||
&& acceptableBlocks.contains((Integer)world.getBlockAt(X, Y + 1, Z).getTypeId()) // above target block breathable
|
||||
&& !acceptableBlocks.contains(below) // below target block not breathable (probably solid)
|
||||
&& !painfulBlocks.contains(below) // below target block not something painful
|
||||
);
|
||||
}
|
||||
|
||||
// find closest safe Y position from the starting position
|
||||
private double getSafeY(World world, int X, int Y, int Z)
|
||||
{
|
||||
// Expanding Y search method adapted from Acru's code in the Nether plugin
|
||||
int limTop = 120, limBot = 1;
|
||||
|
||||
for(int y1 = Y, y2 = Y; (y1 > limBot) || (y2 < limTop); y1--, y2++){
|
||||
// Look below.
|
||||
if(y1 > limBot){
|
||||
if (isSafeSpot(world, X, y1, Z))
|
||||
return (double)y1;
|
||||
}
|
||||
|
||||
// Look above.
|
||||
if(y2 < limTop && y2 != y1){
|
||||
if (isSafeSpot(world, X, y2, Z))
|
||||
return (double)y2;
|
||||
}
|
||||
}
|
||||
|
||||
return -1.0; // no safe Y location?!?!? Must be a rare spot in a Nether world or something
|
||||
}
|
||||
}
|
223
src/com/wimbli/WorldBorder/Config.java
Normal file
223
src/com/wimbli/WorldBorder/Config.java
Normal file
@ -0,0 +1,223 @@
|
||||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.bukkit.util.config.ConfigurationNode;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Config
|
||||
{
|
||||
// private stuff used within this class
|
||||
private static WorldBorder plugin;
|
||||
private static Configuration cfg = null;
|
||||
private static PermissionHandler Permissions = null;
|
||||
private static final Logger mcLog = Logger.getLogger("Minecraft");
|
||||
public static DecimalFormat coord = new DecimalFormat("0.0");
|
||||
public static final boolean DEBUG = false;
|
||||
|
||||
// actual configuration values which can be changed
|
||||
private static boolean shapeRound = false;
|
||||
private static Map<String, BorderData> borders = new HashMap<String, BorderData>();
|
||||
private static String message;
|
||||
|
||||
public static void setBorder(String world, BorderData border)
|
||||
{
|
||||
borders.put(world, border);
|
||||
Log("Border set. " + BorderDescription(world));
|
||||
save(true);
|
||||
}
|
||||
public static void setBorder(String world, int radius, double x, double z)
|
||||
{
|
||||
setBorder(world, new BorderData(x, z, radius));
|
||||
}
|
||||
|
||||
public static void removeBorder(String world)
|
||||
{
|
||||
borders.remove(world);
|
||||
Log("Removed border for world \"" + world + "\".");
|
||||
save(true);
|
||||
}
|
||||
|
||||
public static void removeAllBorders()
|
||||
{
|
||||
borders.clear();
|
||||
Log("Removed all borders for all worlds.");
|
||||
save(true);
|
||||
}
|
||||
|
||||
public static String BorderDescription(String world)
|
||||
{
|
||||
BorderData border = borders.get(world);
|
||||
if (border == null)
|
||||
return "No border was found for the world \"" + world + "\".";
|
||||
else
|
||||
return "World \"" + world + "\" has border " + border.toString();
|
||||
}
|
||||
|
||||
public static Set<String> BorderDescriptions()
|
||||
{
|
||||
Set<String> output = new HashSet<String>();
|
||||
|
||||
Iterator world = borders.keySet().iterator();
|
||||
while(world.hasNext())
|
||||
{
|
||||
output.add( BorderDescription((String)world.next()) );
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static BorderData Border(String world)
|
||||
{
|
||||
return borders.get(world);
|
||||
}
|
||||
|
||||
public static void setMessage(String msg)
|
||||
{
|
||||
message = msg;
|
||||
Log("Border message is now set to: " + msg);
|
||||
save(true);
|
||||
}
|
||||
|
||||
public static String Message()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void setShape(boolean round)
|
||||
{
|
||||
shapeRound = round;
|
||||
Log("Set border shape to " + (round ? "round" : "square") + ".");
|
||||
save(true);
|
||||
}
|
||||
|
||||
public static boolean ShapeRound()
|
||||
{
|
||||
return shapeRound;
|
||||
}
|
||||
|
||||
public static void loadPermissions(WorldBorder plugin)
|
||||
{
|
||||
if (Permissions != null || plugin == null)
|
||||
return;
|
||||
|
||||
Plugin test = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
|
||||
if (test != null)
|
||||
{
|
||||
Permissions = ((Permissions)test).getHandler();
|
||||
LogConfig("Will use plugin for permissions: "+((Permissions)test).getDescription().getFullName());
|
||||
} else {
|
||||
LogConfig("Permissions plugin not found. Only Ops will have access to this plugin's commands.");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean HasPermission(Player player, String request)
|
||||
{
|
||||
if (player == null) // console, always permitted
|
||||
return true;
|
||||
else if (player.isOp()) // Op, always permitted
|
||||
return true;
|
||||
else if (Permissions == null // Permissions plugin not available, or doesn't have permission
|
||||
|| !Permissions.permission(player, "worldborder." + request))
|
||||
{
|
||||
player.sendMessage("You do not have sufficient permissions to do that.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Log(Level lvl, String text)
|
||||
{
|
||||
String name = (plugin == null) ? "WorldBorder" : plugin.getDescription().getName();
|
||||
mcLog.log(lvl, String.format("[%s] %s", name, text));
|
||||
}
|
||||
public static void Log(String text)
|
||||
{
|
||||
Log(Level.INFO, text);
|
||||
}
|
||||
public static void LogWarn(String text)
|
||||
{
|
||||
Log(Level.WARNING, text);
|
||||
}
|
||||
public static void LogConfig(String text)
|
||||
{
|
||||
Log(Level.INFO, "[CONFIG] " + text);
|
||||
}
|
||||
|
||||
public static void load(WorldBorder master, boolean logIt)
|
||||
{ // load config from file
|
||||
plugin = master;
|
||||
cfg = plugin.getConfiguration();
|
||||
|
||||
message = cfg.getString("message");
|
||||
shapeRound = cfg.getBoolean("round-border", false);
|
||||
LogConfig("Using " + (shapeRound ? "round" : "square") + " border shape.");
|
||||
|
||||
borders.clear();
|
||||
|
||||
Map<String, ConfigurationNode> worlds = cfg.getNodes("worlds");
|
||||
if (worlds != null)
|
||||
{
|
||||
Iterator world = worlds.entrySet().iterator();
|
||||
while(world.hasNext())
|
||||
{
|
||||
Entry wdata = (Entry)world.next();
|
||||
String name = (String)wdata.getKey();
|
||||
ConfigurationNode bord = (ConfigurationNode)wdata.getValue();
|
||||
BorderData border = new BorderData(bord.getDouble("x", 0), bord.getDouble("z", 0), bord.getInt("radius", 0));
|
||||
borders.put(name, border);
|
||||
LogConfig(BorderDescription(name));
|
||||
}
|
||||
}
|
||||
|
||||
if (message == null || message.isEmpty())
|
||||
{ // store defaults
|
||||
LogConfig("Configuration not present, creating new file.");
|
||||
message = "You have reached the edge of this world.";
|
||||
shapeRound = false;
|
||||
save(false);
|
||||
}
|
||||
else if (logIt)
|
||||
LogConfig("Configuration loaded.");
|
||||
}
|
||||
|
||||
public static void save(boolean logIt)
|
||||
{ // save config to file
|
||||
if (cfg == null) return;
|
||||
|
||||
cfg.setProperty("message", message);
|
||||
cfg.setProperty("round-border", shapeRound);
|
||||
|
||||
cfg.removeProperty("worlds");
|
||||
Iterator world = borders.entrySet().iterator();
|
||||
while(world.hasNext())
|
||||
{
|
||||
Entry wdata = (Entry)world.next();
|
||||
String name = (String)wdata.getKey();
|
||||
BorderData bord = (BorderData)wdata.getValue();
|
||||
cfg.setProperty("worlds." + name + ".x", bord.getX());
|
||||
cfg.setProperty("worlds." + name + ".z", bord.getZ());
|
||||
cfg.setProperty("worlds." + name + ".radius", bord.getRadius());
|
||||
}
|
||||
|
||||
cfg.save();
|
||||
|
||||
if (logIt)
|
||||
LogConfig("Configuration saved.");
|
||||
}
|
||||
}
|
314
src/com/wimbli/WorldBorder/WBCommand.java
Normal file
314
src/com/wimbli/WorldBorder/WBCommand.java
Normal file
@ -0,0 +1,314 @@
|
||||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class WBCommand implements CommandExecutor
|
||||
{
|
||||
private WorldBorder plugin;
|
||||
|
||||
public WBCommand (WorldBorder plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split)
|
||||
{
|
||||
Player player = (sender instanceof Player) ? (Player)sender : null;
|
||||
|
||||
String cmd = ChatColor.AQUA + ((player == null) ? "wborder" : "/wborder");
|
||||
String cmdW = ChatColor.AQUA + ((player == null) ? "wborder " + ChatColor.GREEN + "<world>" : "/wborder " + ChatColor.DARK_AQUA + "[world]") + ChatColor.AQUA;
|
||||
|
||||
// "set" command from player or console, world specified
|
||||
if (split.length == 5 && split[1].equalsIgnoreCase("set"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "set")) return true;
|
||||
|
||||
World world = sender.getServer().getWorld(split[0]);
|
||||
if (world == null)
|
||||
sender.sendMessage("The world you specified (\"" + split[0] + "\") could not be found on the server, but data for it will be stored anyway.");
|
||||
|
||||
if(cmdSet(sender, split[0], split, 2) && player != null)
|
||||
sender.sendMessage("Border has been set. " + Config.BorderDescription(split[0]));
|
||||
}
|
||||
|
||||
// "set" command from player, using current world, X and Z specified
|
||||
else if (split.length == 4 && split[0].equalsIgnoreCase("set") && player != null)
|
||||
{
|
||||
if (!Config.HasPermission(player, "set")) return true;
|
||||
|
||||
String world = player.getWorld().getName();
|
||||
|
||||
if (cmdSet(sender, world, split, 1))
|
||||
sender.sendMessage("Border has been set. " + Config.BorderDescription(world));
|
||||
}
|
||||
|
||||
// "set" command from player, using current world, X and Z NOT specified
|
||||
else if (split.length == 2 && split[0].equalsIgnoreCase("set") && player != null)
|
||||
{
|
||||
if (!Config.HasPermission(player, "set")) return true;
|
||||
|
||||
String world = player.getWorld().getName();
|
||||
|
||||
double x = player.getLocation().getX();
|
||||
double z = player.getLocation().getZ();
|
||||
int radius;
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(split[1]);
|
||||
}
|
||||
catch(NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "The radius value must be an integer.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Config.setBorder(world, radius, x, z);
|
||||
sender.sendMessage("Border has been set. " + Config.BorderDescription(world));
|
||||
}
|
||||
|
||||
// "radius" command from player or console, world specified
|
||||
else if (split.length == 3 && split[1].equalsIgnoreCase("radius"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "radius")) return true;
|
||||
|
||||
String world = split[0];
|
||||
|
||||
BorderData border = Config.Border(world);
|
||||
if (border == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That world (\"" + world + "\") must first have a border set normally.");
|
||||
return true;
|
||||
}
|
||||
|
||||
double x = border.getX();
|
||||
double z = border.getZ();
|
||||
int radius;
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(split[1]);
|
||||
}
|
||||
catch(NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "The radius value must be an integer.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Config.setBorder(world, radius, x, z);
|
||||
sender.sendMessage("Radius has been set. " + Config.BorderDescription(world));
|
||||
}
|
||||
|
||||
// "radius" command from player, using current world
|
||||
else if (split.length == 2 && split[0].equalsIgnoreCase("radius") && player != null)
|
||||
{
|
||||
if (!Config.HasPermission(player, "radius")) return true;
|
||||
|
||||
String world = player.getWorld().getName();
|
||||
|
||||
BorderData border = Config.Border(world);
|
||||
if (border == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This world (\"" + world + "\") must first have a border set normally.");
|
||||
return true;
|
||||
}
|
||||
|
||||
double x = border.getX();
|
||||
double z = border.getZ();
|
||||
int radius;
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(split[1]);
|
||||
}
|
||||
catch(NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "The radius value must be an integer.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Config.setBorder(world, radius, x, z);
|
||||
sender.sendMessage("Radius has been set. " + Config.BorderDescription(world));
|
||||
}
|
||||
|
||||
// "clear" command from player or console, world specified
|
||||
else if (split.length == 2 && split[1].equalsIgnoreCase("clear"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "clear")) return true;
|
||||
|
||||
String world = split[0];
|
||||
BorderData border = Config.Border(world);
|
||||
if (border == null)
|
||||
{
|
||||
sender.sendMessage("The world you specified (\"" + world + "\") does not have a border set.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Config.removeBorder(world);
|
||||
|
||||
if (player != null)
|
||||
sender.sendMessage("Border cleared for world \"" + world + "\".");
|
||||
}
|
||||
|
||||
// "clear" command from player, using current world
|
||||
else if (split.length == 1 && split[0].equalsIgnoreCase("clear") && player != null)
|
||||
{
|
||||
if (!Config.HasPermission(player, "clear")) return true;
|
||||
|
||||
String world = player.getWorld().getName();
|
||||
BorderData border = Config.Border(world);
|
||||
if (border == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Your current world (\"" + world + "\") does not have a border set.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Config.removeBorder(world);
|
||||
sender.sendMessage("Border cleared for world \"" + world + "\".");
|
||||
}
|
||||
|
||||
// "clear all" command from player or console
|
||||
else if (split.length == 2 && split[0].equalsIgnoreCase("clear") && split[1].equalsIgnoreCase("all"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "clear")) return true;
|
||||
|
||||
Config.removeAllBorders();
|
||||
|
||||
if (player != null)
|
||||
sender.sendMessage("All borders cleared for all worlds.");
|
||||
}
|
||||
|
||||
// "list" command from player or console
|
||||
else if (split.length == 1 && split[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "list")) return true;
|
||||
|
||||
sender.sendMessage("Border shape for all worlds is \"" + (Config.ShapeRound() ? "round" : "square") + "\".");
|
||||
|
||||
Set<String> list = Config.BorderDescriptions();
|
||||
|
||||
if (list.isEmpty())
|
||||
{
|
||||
sender.sendMessage("There are no borders currently set.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Iterator listItem = list.iterator();
|
||||
while(listItem.hasNext())
|
||||
{
|
||||
sender.sendMessage( (String)listItem.next() );
|
||||
}
|
||||
}
|
||||
|
||||
// "shape" command from player or console
|
||||
else if (split.length == 2 && split[0].equalsIgnoreCase("shape"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "shape")) return true;
|
||||
|
||||
if (split[1].equalsIgnoreCase("square"))
|
||||
Config.setShape(false);
|
||||
else if (split[1].equalsIgnoreCase("round"))
|
||||
Config.setShape(true);
|
||||
else
|
||||
{
|
||||
sender.sendMessage("You must specify a shape of \"round\" or \"square\".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
sender.sendMessage("Border shape for all worlds is now set to \"" + (Config.ShapeRound() ? "round" : "square") + "\".");
|
||||
}
|
||||
|
||||
// "getmsg" command from player or console
|
||||
else if (split.length == 1 && split[0].equalsIgnoreCase("getmsg"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "getmsg")) return true;
|
||||
|
||||
sender.sendMessage("Border message is currently set to:");
|
||||
sender.sendMessage(ChatColor.RED + Config.Message());
|
||||
}
|
||||
|
||||
// "setmsg" command from player or console
|
||||
else if (split.length >= 2 && split[0].equalsIgnoreCase("setmsg"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "setmsg")) return true;
|
||||
|
||||
String message = "";
|
||||
for(int i = 1; i < split.length; i++)
|
||||
{
|
||||
if (i != 1)
|
||||
message += ' ';
|
||||
message += split[i];
|
||||
}
|
||||
|
||||
Config.setMessage(message);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
sender.sendMessage("Border message is now set to:");
|
||||
sender.sendMessage(ChatColor.RED + Config.Message());
|
||||
}
|
||||
}
|
||||
|
||||
// "reload" command from player or console
|
||||
else if (split.length == 1 && split[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
if (!Config.HasPermission(player, "reload")) return true;
|
||||
|
||||
if (player != null)
|
||||
Config.Log("Reloading config file at the command of player \"" + player.getName() + "\".");
|
||||
|
||||
Config.load(plugin, true);
|
||||
|
||||
if (player != null)
|
||||
sender.sendMessage("WorldBorder configuration reloaded.");
|
||||
}
|
||||
|
||||
// we couldn't decipher any known commands, so show help
|
||||
else
|
||||
{
|
||||
if (!Config.HasPermission(player, "help")) return true;
|
||||
|
||||
sender.sendMessage(ChatColor.WHITE + plugin.getDescription().getFullName() + " - commands (" + (player != null ? ChatColor.DARK_AQUA + "[optional] " : "") + ChatColor.GREEN + "<required>" + ChatColor.WHITE + "):");
|
||||
if (player != null)
|
||||
sender.sendMessage(cmd+" set " + ChatColor.GREEN + "<radius>" + ChatColor.WHITE + " - set world border, centered on you.");
|
||||
sender.sendMessage(cmdW+" set " + ChatColor.GREEN + "<radius> <x> <z>" + ChatColor.WHITE + " - set world border.");
|
||||
sender.sendMessage(cmdW+" radius " + ChatColor.GREEN + "<radius>" + ChatColor.WHITE + " - change border radius for this world.");
|
||||
sender.sendMessage(cmdW+" clear" + ChatColor.WHITE + " - remove border for this world.");
|
||||
sender.sendMessage(cmd+" clear all" + ChatColor.WHITE + " - remove border for all worlds.");
|
||||
sender.sendMessage(cmd+" list" + ChatColor.WHITE + " - show border information for all worlds.");
|
||||
sender.sendMessage(cmd+" shape " + ChatColor.GREEN + "<round|square>" + ChatColor.WHITE + " - set the border shape.");
|
||||
sender.sendMessage(cmd+" getmsg" + ChatColor.WHITE + " - display border message.");
|
||||
sender.sendMessage(cmd+" setmsg " + ChatColor.GREEN + "<text>" + ChatColor.WHITE + " - set border message.");
|
||||
if (player != null)
|
||||
sender.sendMessage(cmd+" reload" + ChatColor.WHITE + " - re-load data from config.yml.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean cmdSet(CommandSender sender, String world, String[] data, int offset)
|
||||
{
|
||||
int radius;
|
||||
double x, z;
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(data[offset]);
|
||||
x = Double.parseDouble(data[offset+1]);
|
||||
z = Double.parseDouble(data[offset+2]);
|
||||
}
|
||||
catch(NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "The radius value must be an integer and the x and z values must be numerical.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Config.setBorder(world, radius, x, z);
|
||||
return true;
|
||||
}
|
||||
}
|
147
src/com/wimbli/WorldBorder/WBPlayerListener.java
Normal file
147
src/com/wimbli/WorldBorder/WBPlayerListener.java
Normal file
@ -0,0 +1,147 @@
|
||||
package com.wimbli.WorldBorder;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class WBPlayerListener extends PlayerListener
|
||||
{
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (player == null) return;
|
||||
Location loc = player.getLocation();
|
||||
if (loc == null) return;
|
||||
World world = loc.getWorld();
|
||||
if (world == null) return;
|
||||
BorderData border = Config.Border(world.getName());
|
||||
if (border == null) return;
|
||||
|
||||
if (border.insideBorder(loc.getX(), loc.getZ(), Config.ShapeRound()))
|
||||
return;
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
Config.LogWarn("Border crossing. Border " + border.toString());
|
||||
Config.LogWarn("Player position X: " + Config.coord.format(loc.getX()) + " Y: " + Config.coord.format(loc.getY()) + " Z: " + Config.coord.format(loc.getZ()));
|
||||
}
|
||||
|
||||
Location newLoc = border.correctedPosition(loc, Config.ShapeRound());
|
||||
|
||||
// it's remotely possible (such as in the Nether) a suitable location isn't available, in which case...
|
||||
if (newLoc == null)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
Config.LogWarn("Target new location unviable, using spawn.");
|
||||
newLoc = player.getServer().getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
Config.LogWarn("New position X: " + Config.coord.format(newLoc.getX()) + " Y: " + Config.coord.format(newLoc.getY()) + " Z: " + Config.coord.format(newLoc.getZ()));
|
||||
|
||||
player.sendMessage(ChatColor.RED + Config.Message());
|
||||
player.teleport(newLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (player == null) return;
|
||||
Location loc = event.getTo();
|
||||
if (loc == null) return;
|
||||
World world = loc.getWorld();
|
||||
if (world == null) return;
|
||||
BorderData border = Config.Border(world.getName());
|
||||
if (border == null) return;
|
||||
|
||||
if (border.insideBorder(loc.getX(), loc.getZ(), Config.ShapeRound()))
|
||||
return;
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
Config.LogWarn("Border crossing. Border " + border.toString());
|
||||
Config.LogWarn("Player position X: " + Config.coord.format(loc.getX()) + " Y: " + Config.coord.format(loc.getY()) + " Z: " + Config.coord.format(loc.getZ()));
|
||||
}
|
||||
|
||||
Location newLoc = border.correctedPosition(loc, Config.ShapeRound());
|
||||
|
||||
if (newLoc == null)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
Config.LogWarn("Target new location unviable, using spawn.");
|
||||
newLoc = player.getServer().getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
Config.LogWarn("New position X: " + Config.coord.format(newLoc.getX()) + " Y: " + Config.coord.format(newLoc.getY()) + " Z: " + Config.coord.format(newLoc.getZ()));
|
||||
|
||||
player.sendMessage(ChatColor.RED + Config.Message());
|
||||
|
||||
if (!player.isInsideVehicle())
|
||||
player.teleport(newLoc);
|
||||
else
|
||||
{
|
||||
newLoc.setY(newLoc.getY() + 1);
|
||||
player.getVehicle().setVelocity(new Vector(0, 0, 0));
|
||||
player.getVehicle().teleport(newLoc);
|
||||
}
|
||||
|
||||
event.setTo(newLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (player == null) return;
|
||||
Location loc = event.getTo();
|
||||
if (loc == null) return;
|
||||
World world = loc.getWorld();
|
||||
if (world == null) return;
|
||||
BorderData border = Config.Border(world.getName());
|
||||
if (border == null) return;
|
||||
|
||||
if (border.insideBorder(loc.getX(), loc.getZ(), Config.ShapeRound()))
|
||||
return;
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
Config.LogWarn("Border crossing. Border " + border.toString());
|
||||
Config.LogWarn("Player position X: " + Config.coord.format(loc.getX()) + " Y: " + Config.coord.format(loc.getY()) + " Z: " + Config.coord.format(loc.getZ()));
|
||||
}
|
||||
|
||||
Location newLoc = border.correctedPosition(loc, Config.ShapeRound());
|
||||
|
||||
if (newLoc == null)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
Config.LogWarn("Target new location unviable, using spawn.");
|
||||
newLoc = player.getServer().getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
Config.LogWarn("New position X: " + Config.coord.format(newLoc.getX()) + " Y: " + Config.coord.format(newLoc.getY()) + " Z: " + Config.coord.format(newLoc.getZ()));
|
||||
|
||||
player.sendMessage(ChatColor.RED + Config.Message());
|
||||
|
||||
if (!player.isInsideVehicle())
|
||||
player.teleport(newLoc);
|
||||
else
|
||||
{
|
||||
newLoc.setY(newLoc.getY() + 1);
|
||||
player.getVehicle().setVelocity(new Vector(0, 0, 0));
|
||||
player.getVehicle().teleport(newLoc);
|
||||
}
|
||||
|
||||
event.setTo(newLoc);
|
||||
}
|
||||
}
|
44
src/com/wimbli/WorldBorder/WorldBorder.java
Normal file
44
src/com/wimbli/WorldBorder/WorldBorder.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.wimbli.WorldBorder;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brett Flannigan
|
||||
*/
|
||||
public class WorldBorder extends JavaPlugin
|
||||
{
|
||||
WBPlayerListener playerListener = new WBPlayerListener();
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
PluginDescriptionFile desc = this.getDescription();
|
||||
System.out.println( desc.getName() + " version " + desc.getVersion() + " loading" );
|
||||
|
||||
// Load (or create new) config file, and connect to Permissions if it's available
|
||||
Config.load(this, false);
|
||||
Config.loadPermissions(this);
|
||||
|
||||
// Well I for one find this info useful, so...
|
||||
Location spawn = getServer().getWorlds().get(0).getSpawnLocation();
|
||||
System.out.println("For reference, the main world's spawn location is at X: " + Config.coord.format(spawn.getX()) + " Y: " + Config.coord.format(spawn.getY()) + " Z: " + Config.coord.format(spawn.getZ()));
|
||||
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.High, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, this.playerListener, Event.Priority.High, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.High, this);
|
||||
|
||||
// our one real command, though it does also have aliases "wb" and "worldborder"
|
||||
getCommand("wborder").setExecutor(new WBCommand(this));
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
PluginDescriptionFile desc = this.getDescription();
|
||||
System.out.println( desc.getName() + " version " + desc.getVersion() + " shutting down" );
|
||||
}
|
||||
}
|
20
src/plugin.yml
Normal file
20
src/plugin.yml
Normal file
@ -0,0 +1,20 @@
|
||||
name: WorldBorder
|
||||
author: Brettflan
|
||||
description: Limit the size of your worlds with a border, round or square.
|
||||
version: 0.9
|
||||
main: com.wimbli.WorldBorder.WorldBorder
|
||||
commands:
|
||||
wborder:
|
||||
description: Primary command for WorldBorder.
|
||||
aliases: [worldborder, wb]
|
||||
usage: |
|
||||
/<command> - list available commands (show help).
|
||||
/<command> set <radius> - set world border, centered on you.
|
||||
/<command> [world] set <radius> <x> <z> - set world border.
|
||||
/<command> radius <radius> - change border radius for this world.
|
||||
/<command> [world] clear - remove border for this world.
|
||||
/<command> clear all - remove border for all worlds.
|
||||
/<command> list - show border information for all worlds.
|
||||
/<command> shape <round|square> - set the border shape.
|
||||
/<command> getmsg - display border message.
|
||||
/<command> setmsg <text> - set border message.
|
Loading…
Reference in New Issue
Block a user