Update to Spigot-1.16.5

Update Vault / WorldEdit / WorldGuard version
Update Plugin
Fix CR/LF
This commit is contained in:
Arnaud G. GIBERT 2021-04-24 11:11:25 +02:00
parent aabf6db1ae
commit 0506ebc2c2
18 changed files with 2791 additions and 2759 deletions

146
build.xml
View File

@ -1,73 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for --> <!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. --> <!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) --> <!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. --> <!-- 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 --> <!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. --> <!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> <!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.--> <!-- in the project's Project Properties dialog box.-->
<project name="Quake" default="default" basedir="."> <project name="Quake" default="default" basedir=".">
<description>Builds, tests, and runs the project Quake.</description> <description>Builds, tests, and runs the project Quake.</description>
<import file="nbproject/build-impl.xml"/> <import file="nbproject/build-impl.xml"/>
<!-- <!--
There exist several targets which are by default empty and which can be There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed used for execution of your tasks. These targets are usually executed
before and after some main targets. They are: before and after some main targets. They are:
-pre-init: called before initialization of project properties -pre-init: called before initialization of project properties
-post-init: called after initialization of project properties -post-init: called after initialization of project properties
-pre-compile: called before javac compilation -pre-compile: called before javac compilation
-post-compile: called after javac compilation -post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file -pre-compile-single: called before javac compilation of single file
-post-compile-single: called after 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 -pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after 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 -pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test -post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building -pre-jar: called before JAR building
-post-jar: called after JAR building -post-jar: called after JAR building
-post-clean: called after cleaning build products -post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.) (Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this: Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile"> <target name="-post-compile">
<obfuscate> <obfuscate>
<fileset dir="${build.classes.dir}"/> <fileset dir="${build.classes.dir}"/>
</obfuscate> </obfuscate>
</target> </target>
For list of available properties check the imported For list of available properties check the imported
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets. Another way to customize the build is by overriding existing main targets.
The targets of interest are: The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation -init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution -init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging -init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution -init-macrodef-java: defines macro for class execution
-do-jar: JAR building -do-jar: JAR building
run: execution of project run: execution of project
-javadoc-build: Javadoc generation -javadoc-build: Javadoc generation
test-report: JUnit report generation test-report: JUnit report generation
An example of overriding the target for project execution could look like this: An example of overriding the target for project execution could look like this:
<target name="run" depends="Quake-impl.jar"> <target name="run" depends="Quake-impl.jar">
<exec dir="bin" executable="launcher.exe"> <exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/> <arg file="${dist.jar}"/>
</exec> </exec>
</target> </target>
Notice that the overridden target depends on the jar target and not only on 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 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 properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
--> -->
</project> </project>

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
build.xml.data.CRC32=477a4906 build.xml.data.CRC32=477a4906
build.xml.script.CRC32=fbf2856b build.xml.script.CRC32=fbf2856b
build.xml.stylesheet.CRC32=8064a381@1.79.1.48 build.xml.stylesheet.CRC32=8064a381@1.79.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # 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. # 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=477a4906 nbproject/build-impl.xml.data.CRC32=477a4906
nbproject/build-impl.xml.script.CRC32=5f55f531 nbproject/build-impl.xml.script.CRC32=5f55f531
nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48

View File

@ -1,120 +1,120 @@
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processors.list= annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Quake application.title=Quake
application.vendor=Bl4ckSkull666 application.vendor=Bl4ckSkull666
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
build.classes.dir=${build.dir}/classes build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
build.dir=build build.dir=build
build.generated.dir=${build.dir}/generated build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here: # Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport: # Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket #debug.transport=dt_socket
debug.classpath=\ debug.classpath=\
${run.classpath} ${run.classpath}
debug.modulepath=\ debug.modulepath=\
${run.modulepath} ${run.modulepath}
debug.test.classpath=\ debug.test.classpath=\
${run.test.classpath} ${run.test.classpath}
debug.test.modulepath=\ debug.test.modulepath=\
${run.test.modulepath} ${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar # Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes= dist.archive.excludes=
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
dist.dir=dist dist.dir=dist
dist.jar=${dist.dir}/Quake.jar dist.jar=${dist.dir}/Quake.jar
dist.javadoc.dir=${dist.dir}/javadoc dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath= endorsed.classpath=
excludes= excludes=
file.reference.Quake.jar=dist\\Quake.jar file.reference.Quake.jar=dist\\Quake.jar
file.reference.spigot-1.12.1.jar=../../../AMC-Server.de/JARs/spigot-1.12.1.jar file.reference.spigot-1.14.4.jar=../../minecraft/spigot-1.14.4.jar
file.reference.spigot-1.14.4.jar=../../../Minecraft/Jars/Spigot/spigot-1.14.4.jar file.reference.spigot-1.16.5.jar=../../minecraft/spigot-1.16.5.jar
file.reference.Vault_v1.7.2.jar=../../../Minecraft/Jars/1.14/Vault_v1.7.2.jar file.reference.Vault.jar=../../minecraft/Vault-1.7.3.jar
file.reference.WorldEdit_v7.1.0-b4675.jar=../../../Minecraft/Jars/1.14/WorldEdit_v7.1.0-b4675.jar file.reference.WorldEdit.jar=../../minecraft/WorldEdit-Bukkit-7.2.4.jar
file.reference.WorldGuard_v7.0.1-b1983.jar=../../../Minecraft/Jars/1.14/WorldGuard_v7.0.1-b1983.jar file.reference.WorldGuard.jar=../../minecraft/WorldGuard-Bukkit-7.0.4.jar
includes=** includes=**
jar.archive.disabled=${jnlp.enabled} jar.archive.disabled=${jnlp.enabled}
jar.compress=false jar.compress=false
jar.index=${jnlp.enabled} jar.index=${jnlp.enabled}
javac.classpath=\ javac.classpath=\
${file.reference.spigot-1.12.1.jar}:\ ${file.reference.spigot-1.14.4.jar}:\
${file.reference.spigot-1.14.4.jar}:\ ${file.reference.spigot-1.16.5.jar}:\
${file.reference.Vault_v1.7.2.jar}:\ ${file.reference.Vault.jar}:\
${file.reference.WorldEdit_v7.1.0-b4675.jar}:\ ${file.reference.WorldEdit.jar}:\
${file.reference.WorldGuard_v7.0.1-b1983.jar}:\ ${file.reference.WorldGuard.jar}:\
${file.reference.Quake.jar} ${file.reference.Quake.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
javac.external.vm=true javac.external.vm=true
javac.modulepath= javac.modulepath=
javac.processormodulepath= javac.processormodulepath=
javac.processorpath=\ javac.processorpath=\
${javac.classpath} ${javac.classpath}
javac.source=1.8 javac.source=1.8
javac.target=1.8 javac.target=1.8
javac.test.classpath=\ javac.test.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
${build.classes.dir} ${build.classes.dir}
javac.test.modulepath=\ javac.test.modulepath=\
${javac.modulepath} ${javac.modulepath}
javac.test.processorpath=\ javac.test.processorpath=\
${javac.test.classpath} ${javac.test.classpath}
javadoc.additionalparam= javadoc.additionalparam=
javadoc.author=false javadoc.author=false
javadoc.encoding=${source.encoding} javadoc.encoding=${source.encoding}
javadoc.noindex=false javadoc.noindex=false
javadoc.nonavbar=false javadoc.nonavbar=false
javadoc.notree=false javadoc.notree=false
javadoc.private=false javadoc.private=false
javadoc.splitindex=true javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
javadoc.windowtitle= javadoc.windowtitle=
jnlp.codebase.type=no.codebase jnlp.codebase.type=no.codebase
jnlp.descriptor=application jnlp.descriptor=application
jnlp.enabled=false jnlp.enabled=false
jnlp.mixed.code=default jnlp.mixed.code=default
jnlp.offline-allowed=false jnlp.offline-allowed=false
jnlp.signed=false jnlp.signed=false
jnlp.signing= jnlp.signing=
jnlp.signing.alias= jnlp.signing.alias=
jnlp.signing.keystore= jnlp.signing.keystore=
main.class= main.class=
# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. # Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
manifest.custom.application.library.allowable.codebase= manifest.custom.application.library.allowable.codebase=
# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. # Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
manifest.custom.caller.allowable.codebase= manifest.custom.caller.allowable.codebase=
# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed # Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed
manifest.custom.codebase= manifest.custom.codebase=
# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) # Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions)
manifest.custom.permissions= manifest.custom.permissions=
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false mkdist.disabled=false
platform.active=default_platform platform.active=default_platform
run.classpath=\ run.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
${build.classes.dir} ${build.classes.dir}
# Space-separated list of JVM arguments used when running the project. # 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. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value: # To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs= run.jvmargs=
run.modulepath=\ run.modulepath=\
${javac.modulepath} ${javac.modulepath}
run.test.classpath=\ run.test.classpath=\
${javac.test.classpath}:\ ${javac.test.classpath}:\
${build.test.classes.dir} ${build.test.classes.dir}
run.test.modulepath=\ run.test.modulepath=\
${javac.test.modulepath} ${javac.test.modulepath}
source.encoding=UTF-8 source.encoding=UTF-8
src.dir=src src.dir=src
test.src.dir=test test.src.dir=testy

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1"> <project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type> <type>org.netbeans.modules.java.j2seproject</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>Quake</name> <name>Quake</name>
<source-roots> <source-roots>
<root id="src.dir"/> <root id="src.dir"/>
</source-roots> </source-roots>
<test-roots> <test-roots>
<root id="test.src.dir"/> <root id="test.src.dir"/>
</test-roots> </test-roots>
</data> </data>
</configuration> </configuration>
</project> </project>

View File

@ -1,166 +1,166 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package com.Geekpower14.Quake.Versions; package com.Geekpower14.Quake.Versions;
import com.Geekpower14.Quake.Quake; import com.Geekpower14.Quake.Quake;
import org.bukkit.Material; import org.bukkit.Material;
/** /**
* *
* @author Bl4ckSkull666 * @author Bl4ckSkull666
*/ */
public class GetMaterials { public class GetMaterials {
private static Material _sign = null; private static Material _sign = null;
private static Material _bed = null; private static Material _bed = null;
private static Material _hoeDiamand = null; private static Material _hoeDiamand = null;
private static Material _leatherChestPlate = null; private static Material _leatherChestPlate = null;
private static Material _jackOLantern = null; private static Material _jackOLantern = null;
private static Material _emerald = null; private static Material _emerald = null;
public static Material GetSign() { public static Material GetSign() {
if(_sign == null) { if(_sign == null) {
if(Quake.getPlugin()._config.isString("materials.sign")) { if(Quake.getPlugin()._config.isString("materials.sign")) {
String mat = Quake.getPlugin()._config.getString("materials.sign"); String mat = Quake.getPlugin()._config.getString("materials.sign");
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase(mat)) { if(m.name().equalsIgnoreCase(mat)) {
_sign = m; _sign = m;
break; break;
} }
} }
} }
if(_sign == null) { if(_sign == null) {
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase("SIGN") || m.name().equalsIgnoreCase("OAK_SIGN")) { if(m.name().equalsIgnoreCase("SIGN") || m.name().equalsIgnoreCase("OAK_SIGN")) {
_sign = m; _sign = m;
break; break;
} }
} }
} }
} }
return _sign; return _sign;
} }
public static Material GetBed() { public static Material GetBed() {
if(_bed == null) { if(_bed == null) {
if(Quake.getPlugin()._config.isString("materials.bed")) { if(Quake.getPlugin()._config.isString("materials.bed")) {
String mat = Quake.getPlugin()._config.getString("materials.bed"); String mat = Quake.getPlugin()._config.getString("materials.bed");
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase(mat)) { if(m.name().equalsIgnoreCase(mat)) {
_bed = m; _bed = m;
break; break;
} }
} }
} }
if(_bed == null) { if(_bed == null) {
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase("BED") || m.name().equalsIgnoreCase("RED_BED")) { if(m.name().equalsIgnoreCase("BED") || m.name().equalsIgnoreCase("RED_BED")) {
_bed = m; _bed = m;
break; break;
} }
} }
} }
} }
return _bed; return _bed;
} }
public static Material GetDiamandHoe() { public static Material GetDiamandHoe() {
if(_hoeDiamand == null) { if(_hoeDiamand == null) {
if(Quake.getPlugin()._config.isString("materials.diamond_hoe")) { if(Quake.getPlugin()._config.isString("materials.diamond_hoe")) {
String mat = Quake.getPlugin()._config.getString("materials.diamond_hoe"); String mat = Quake.getPlugin()._config.getString("materials.diamond_hoe");
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase(mat)) { if(m.name().equalsIgnoreCase(mat)) {
_hoeDiamand = m; _hoeDiamand = m;
break; break;
} }
} }
} }
if(_hoeDiamand == null) { if(_hoeDiamand == null) {
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase("DIAMOND_HOE")) { if(m.name().equalsIgnoreCase("DIAMOND_HOE")) {
_hoeDiamand = m; _hoeDiamand = m;
break; break;
} }
} }
} }
} }
return _hoeDiamand; return _hoeDiamand;
} }
public static Material GetLeatherChestplate() { public static Material GetLeatherChestplate() {
if(_leatherChestPlate == null) { if(_leatherChestPlate == null) {
if(Quake.getPlugin()._config.isString("materials.leather_chestplate")) { if(Quake.getPlugin()._config.isString("materials.leather_chestplate")) {
String mat = Quake.getPlugin()._config.getString("materials.leather_chestplate"); String mat = Quake.getPlugin()._config.getString("materials.leather_chestplate");
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase(mat)) { if(m.name().equalsIgnoreCase(mat)) {
_leatherChestPlate = m; _leatherChestPlate = m;
break; break;
} }
} }
} }
if(_leatherChestPlate == null) { if(_leatherChestPlate == null) {
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase("LEATHER_CHESTPLATE")) { if(m.name().equalsIgnoreCase("LEATHER_CHESTPLATE")) {
_leatherChestPlate = m; _leatherChestPlate = m;
break; break;
} }
} }
} }
} }
return _leatherChestPlate; return _leatherChestPlate;
} }
public static Material GetJackOLantern() { public static Material GetJackOLantern() {
if(_jackOLantern == null) { if(_jackOLantern == null) {
if(Quake.getPlugin()._config.isString("materials.jack_o_lantern")) { if(Quake.getPlugin()._config.isString("materials.jack_o_lantern")) {
String mat = Quake.getPlugin()._config.getString("materials.jack_o_lantern"); String mat = Quake.getPlugin()._config.getString("materials.jack_o_lantern");
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase(mat)) { if(m.name().equalsIgnoreCase(mat)) {
_jackOLantern = m; _jackOLantern = m;
break; break;
} }
} }
} }
if(_jackOLantern == null) { if(_jackOLantern == null) {
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase("JACK_O_LANTERN")) { if(m.name().equalsIgnoreCase("JACK_O_LANTERN")) {
_jackOLantern = m; _jackOLantern = m;
break; break;
} }
} }
} }
} }
return _jackOLantern; return _jackOLantern;
} }
public static Material GetEmerald() { public static Material GetEmerald() {
if(_emerald == null) { if(_emerald == null) {
if(Quake.getPlugin()._config.isString("materials.emerald")) { if(Quake.getPlugin()._config.isString("materials.emerald")) {
String mat = Quake.getPlugin()._config.getString("materials.emerald"); String mat = Quake.getPlugin()._config.getString("materials.emerald");
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase(mat)) { if(m.name().equalsIgnoreCase(mat)) {
_emerald = m; _emerald = m;
break; break;
} }
} }
} }
if(_emerald == null) { if(_emerald == null) {
for(Material m: Material.values()) { for(Material m: Material.values()) {
if(m.name().equalsIgnoreCase("EMERALD")) { if(m.name().equalsIgnoreCase("EMERALD")) {
_emerald = m; _emerald = m;
break; break;
} }
} }
} }
} }
return _emerald; return _emerald;
} }
} }

View File

@ -1,42 +1,42 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package com.Geekpower14.Quake.Versions; package com.Geekpower14.Quake.Versions;
import com.Geekpower14.Quake.Quake; import com.Geekpower14.Quake.Quake;
import org.bukkit.Sound; import org.bukkit.Sound;
/** /**
* *
* @author Bl4ckSkull666 * @author Bl4ckSkull666
*/ */
public class GetSounds { public class GetSounds {
private static Sound _pling = null; private static Sound _pling = null;
public static Sound GetNotePling() { public static Sound GetNotePling() {
if(_pling == null) { if(_pling == null) {
if(Quake.getPlugin()._config.isString("sounds.pling")) { if(Quake.getPlugin()._config.isString("sounds.pling")) {
String search = Quake.getPlugin()._config.getString("sounds.pling"); String search = Quake.getPlugin()._config.getString("sounds.pling");
for(Sound s: Sound.values()) { for(Sound s: Sound.values()) {
if(s.name().equalsIgnoreCase(search)) { if(s.name().equalsIgnoreCase(search)) {
_pling = s; _pling = s;
break; break;
} }
} }
} }
if(_pling == null) { if(_pling == null) {
for(Sound s: Sound.values()) { for(Sound s: Sound.values()) {
if(s.name().equalsIgnoreCase("NOTE_PLING") || if(s.name().equalsIgnoreCase("NOTE_PLING") ||
s.name().equalsIgnoreCase("BLOCK_NOTE_PLING") || s.name().equalsIgnoreCase("BLOCK_NOTE_PLING") ||
s.name().equalsIgnoreCase("BLOCK_NOTE_BLOCK_PLING")) { s.name().equalsIgnoreCase("BLOCK_NOTE_BLOCK_PLING")) {
_pling = s; _pling = s;
break; break;
} }
} }
} }
} }
return _pling; return _pling;
} }
} }

View File

@ -1,25 +1,25 @@
package com.Geekpower14.Quake.Versions; package com.Geekpower14.Quake.Versions;
import com.Geekpower14.Quake.Arena.Arena; import com.Geekpower14.Quake.Arena.Arena;
import net.minecraft.server.v1_14_R1.PacketPlayInClientCommand; import net.minecraft.server.v1_14_R1.PacketPlayInClientCommand;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
/** /**
* *
* @author Bl4ckSkull666 * @author Bl4ckSkull666
*/ */
public class R1_14_1 { public class R1_14_1 {
public static void Respawn(Player p) throws Exception { public static void Respawn(Player p) throws Exception {
PacketPlayInClientCommand ppicc = new PacketPlayInClientCommand(PacketPlayInClientCommand.EnumClientCommand.PERFORM_RESPAWN); PacketPlayInClientCommand ppicc = new PacketPlayInClientCommand(PacketPlayInClientCommand.EnumClientCommand.PERFORM_RESPAWN);
((CraftPlayer)p).getHandle().playerConnection.a(ppicc); ((CraftPlayer)p).getHandle().playerConnection.a(ppicc);
} }
} }

View File

@ -0,0 +1,27 @@
package com.Geekpower14.Quake.Versions;
import com.Geekpower14.Quake.Arena.Arena;
//import net.minecraft.server.v1_14_R1.PacketPlayInClientCommand;
import net.minecraft.server.v1_16_R3.PacketPlayInClientCommand;
import org.bukkit.Sound;
//import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Bl4ckSkull666
*/
public class R1_16_3 {
public static void Respawn(Player p) throws Exception {
PacketPlayInClientCommand ppicc = new PacketPlayInClientCommand(PacketPlayInClientCommand.EnumClientCommand.PERFORM_RESPAWN);
((CraftPlayer)p).getHandle().playerConnection.a(ppicc);
}
}

View File

@ -1,28 +1,33 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package com.Geekpower14.Quake.Versions; package com.Geekpower14.Quake.Versions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
* *
* @author Bl4ckSkull666 * @author Bl4ckSkull666
*/ */
public class SelectVersion { public class SelectVersion {
private static String getVersion() { private static String getVersion() {
String p = Bukkit.getServer().getClass().getPackage().getName(); String p = Bukkit.getServer().getClass().getPackage().getName();
return p.substring(p.lastIndexOf('.') + 1); return p.substring(p.lastIndexOf('.') + 1);
} }
public static void Respawn(Player p) throws Exception { public static void Respawn(Player p) throws Exception {
switch(getVersion()) { switch(getVersion()) {
case "v1_14_R1": case "v1_14_R1":
R1_14_1.Respawn(p); R1_14_1.Respawn(p);
break; break;
} }
} switch(getVersion()) {
} case "v1_16_R3":
R1_16_3.Respawn(p);
break;
}
}
}

View File

@ -1,169 +1,169 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
The Software shall be used for Good, not Evil. The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
/** /**
* Convert a web browser cookie specification to a JSONObject and back. * Convert a web browser cookie specification to a JSONObject and back.
* JSON and Cookies are both notations for name/value pairs. * JSON and Cookies are both notations for name/value pairs.
* @author JSON.org * @author JSON.org
* @version 2010-12-24 * @version 2010-12-24
*/ */
public class Cookie { public class Cookie {
/** /**
* Produce a copy of a string in which the characters '+', '%', '=', ';' * Produce a copy of a string in which the characters '+', '%', '=', ';'
* and control characters are replaced with "%hh". This is a gentle form * and control characters are replaced with "%hh". This is a gentle form
* of URL encoding, attempting to cause as little distortion to the * of URL encoding, attempting to cause as little distortion to the
* string as possible. The characters '=' and ';' are meta characters in * string as possible. The characters '=' and ';' are meta characters in
* cookies. By convention, they are escaped using the URL-encoding. This is * cookies. By convention, they are escaped using the URL-encoding. This is
* only a convention, not a standard. Often, cookies are expected to have * only a convention, not a standard. Often, cookies are expected to have
* encoded values. We encode '=' and ';' because we must. We encode '%' and * encoded values. We encode '=' and ';' because we must. We encode '%' and
* '+' because they are meta characters in URL encoding. * '+' because they are meta characters in URL encoding.
* @param string The source string. * @param string The source string.
* @return The escaped result. * @return The escaped result.
*/ */
public static String escape(String string) { public static String escape(String string) {
char c; char c;
String s = string.trim(); String s = string.trim();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
int length = s.length(); int length = s.length();
for (int i = 0; i < length; i += 1) { for (int i = 0; i < length; i += 1) {
c = s.charAt(i); c = s.charAt(i);
if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') { if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
sb.append('%'); sb.append('%');
sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16)); sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
sb.append(Character.forDigit((char)(c & 0x0f), 16)); sb.append(Character.forDigit((char)(c & 0x0f), 16));
} else { } else {
sb.append(c); sb.append(c);
} }
} }
return sb.toString(); return sb.toString();
} }
/** /**
* Convert a cookie specification string into a JSONObject. The string * Convert a cookie specification string into a JSONObject. The string
* will contain a name value pair separated by '='. The name and the value * will contain a name value pair separated by '='. The name and the value
* will be unescaped, possibly converting '+' and '%' sequences. The * will be unescaped, possibly converting '+' and '%' sequences. The
* cookie properties may follow, separated by ';', also represented as * cookie properties may follow, separated by ';', also represented as
* name=value (except the secure property, which does not have a value). * name=value (except the secure property, which does not have a value).
* The name will be stored under the key "name", and the value will be * The name will be stored under the key "name", and the value will be
* stored under the key "value". This method does not do checking or * stored under the key "value". This method does not do checking or
* validation of the parameters. It only converts the cookie string into * validation of the parameters. It only converts the cookie string into
* a JSONObject. * a JSONObject.
* @param string The cookie specification string. * @param string The cookie specification string.
* @return A JSONObject containing "name", "value", and possibly other * @return A JSONObject containing "name", "value", and possibly other
* members. * members.
* @throws JSONException * @throws JSONException
*/ */
public static JSONObject toJSONObject(String string) throws JSONException { public static JSONObject toJSONObject(String string) throws JSONException {
String name; String name;
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
Object value; Object value;
JSONTokener x = new JSONTokener(string); JSONTokener x = new JSONTokener(string);
jo.put("name", x.nextTo('=')); jo.put("name", x.nextTo('='));
x.next('='); x.next('=');
jo.put("value", x.nextTo(';')); jo.put("value", x.nextTo(';'));
x.next(); x.next();
while (x.more()) { while (x.more()) {
name = unescape(x.nextTo("=;")); name = unescape(x.nextTo("=;"));
if (x.next() != '=') { if (x.next() != '=') {
if (name.equals("secure")) { if (name.equals("secure")) {
value = Boolean.TRUE; value = Boolean.TRUE;
} else { } else {
throw x.syntaxError("Missing '=' in cookie parameter."); throw x.syntaxError("Missing '=' in cookie parameter.");
} }
} else { } else {
value = unescape(x.nextTo(';')); value = unescape(x.nextTo(';'));
x.next(); x.next();
} }
jo.put(name, value); jo.put(name, value);
} }
return jo; return jo;
} }
/** /**
* Convert a JSONObject into a cookie specification string. The JSONObject * Convert a JSONObject into a cookie specification string. The JSONObject
* must contain "name" and "value" members. * must contain "name" and "value" members.
* If the JSONObject contains "expires", "domain", "path", or "secure" * If the JSONObject contains "expires", "domain", "path", or "secure"
* members, they will be appended to the cookie specification string. * members, they will be appended to the cookie specification string.
* All other members are ignored. * All other members are ignored.
* @param jo A JSONObject * @param jo A JSONObject
* @return A cookie specification string * @return A cookie specification string
* @throws JSONException * @throws JSONException
*/ */
public static String toString(JSONObject jo) throws JSONException { public static String toString(JSONObject jo) throws JSONException {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(escape(jo.getString("name"))); sb.append(escape(jo.getString("name")));
sb.append("="); sb.append("=");
sb.append(escape(jo.getString("value"))); sb.append(escape(jo.getString("value")));
if (jo.has("expires")) { if (jo.has("expires")) {
sb.append(";expires="); sb.append(";expires=");
sb.append(jo.getString("expires")); sb.append(jo.getString("expires"));
} }
if (jo.has("domain")) { if (jo.has("domain")) {
sb.append(";domain="); sb.append(";domain=");
sb.append(escape(jo.getString("domain"))); sb.append(escape(jo.getString("domain")));
} }
if (jo.has("path")) { if (jo.has("path")) {
sb.append(";path="); sb.append(";path=");
sb.append(escape(jo.getString("path"))); sb.append(escape(jo.getString("path")));
} }
if (jo.optBoolean("secure")) { if (jo.optBoolean("secure")) {
sb.append(";secure"); sb.append(";secure");
} }
return sb.toString(); return sb.toString();
} }
/** /**
* Convert <code>%</code><i>hh</i> sequences to single characters, and * Convert <code>%</code><i>hh</i> sequences to single characters, and
* convert plus to space. * convert plus to space.
* @param string A string that may contain * @param string A string that may contain
* <code>+</code>&nbsp;<small>(plus)</small> and * <code>+</code>&nbsp;<small>(plus)</small> and
* <code>%</code><i>hh</i> sequences. * <code>%</code><i>hh</i> sequences.
* @return The unescaped string. * @return The unescaped string.
*/ */
public static String unescape(String string) { public static String unescape(String string) {
int length = string.length(); int length = string.length();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
char c = string.charAt(i); char c = string.charAt(i);
if (c == '+') { if (c == '+') {
c = ' '; c = ' ';
} else if (c == '%' && i + 2 < length) { } else if (c == '%' && i + 2 < length) {
int d = JSONTokener.dehexchar(string.charAt(i + 1)); int d = JSONTokener.dehexchar(string.charAt(i + 1));
int e = JSONTokener.dehexchar(string.charAt(i + 2)); int e = JSONTokener.dehexchar(string.charAt(i + 2));
if (d >= 0 && e >= 0) { if (d >= 0 && e >= 0) {
c = (char)(d * 16 + e); c = (char)(d * 16 + e);
i += 2; i += 2;
} }
} }
sb.append(c); sb.append(c);
} }
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,90 +1,90 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
The Software shall be used for Good, not Evil. The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
import java.util.Iterator; import java.util.Iterator;
/** /**
* Convert a web browser cookie list string to a JSONObject and back. * Convert a web browser cookie list string to a JSONObject and back.
* @author JSON.org * @author JSON.org
* @version 2010-12-24 * @version 2010-12-24
*/ */
public class CookieList { public class CookieList {
/** /**
* Convert a cookie list into a JSONObject. A cookie list is a sequence * Convert a cookie list into a JSONObject. A cookie list is a sequence
* of name/value pairs. The names are separated from the values by '='. * of name/value pairs. The names are separated from the values by '='.
* The pairs are separated by ';'. The names and the values * The pairs are separated by ';'. The names and the values
* will be unescaped, possibly converting '+' and '%' sequences. * will be unescaped, possibly converting '+' and '%' sequences.
* *
* To add a cookie to a cooklist, * To add a cookie to a cooklist,
* cookielistJSONObject.put(cookieJSONObject.getString("name"), * cookielistJSONObject.put(cookieJSONObject.getString("name"),
* cookieJSONObject.getString("value")); * cookieJSONObject.getString("value"));
* @param string A cookie list string * @param string A cookie list string
* @return A JSONObject * @return A JSONObject
* @throws JSONException * @throws JSONException
*/ */
public static JSONObject toJSONObject(String string) throws JSONException { public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
JSONTokener x = new JSONTokener(string); JSONTokener x = new JSONTokener(string);
while (x.more()) { while (x.more()) {
String name = Cookie.unescape(x.nextTo('=')); String name = Cookie.unescape(x.nextTo('='));
x.next('='); x.next('=');
jo.put(name, Cookie.unescape(x.nextTo(';'))); jo.put(name, Cookie.unescape(x.nextTo(';')));
x.next(); x.next();
} }
return jo; return jo;
} }
/** /**
* Convert a JSONObject into a cookie list. A cookie list is a sequence * Convert a JSONObject into a cookie list. A cookie list is a sequence
* of name/value pairs. The names are separated from the values by '='. * of name/value pairs. The names are separated from the values by '='.
* The pairs are separated by ';'. The characters '%', '+', '=', and ';' * The pairs are separated by ';'. The characters '%', '+', '=', and ';'
* in the names and values are replaced by "%hh". * in the names and values are replaced by "%hh".
* @param jo A JSONObject * @param jo A JSONObject
* @return A cookie list string * @return A cookie list string
* @throws JSONException * @throws JSONException
*/ */
public static String toString(JSONObject jo) throws JSONException { public static String toString(JSONObject jo) throws JSONException {
boolean b = false; boolean b = false;
Iterator keys = jo.keys(); Iterator keys = jo.keys();
String string; String string;
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
while (keys.hasNext()) { while (keys.hasNext()) {
string = keys.next().toString(); string = keys.next().toString();
if (!jo.isNull(string)) { if (!jo.isNull(string)) {
if (b) { if (b) {
sb.append(';'); sb.append(';');
} }
sb.append(Cookie.escape(string)); sb.append(Cookie.escape(string));
sb.append("="); sb.append("=");
sb.append(Cookie.escape(jo.getString(string))); sb.append(Cookie.escape(jo.getString(string)));
b = true; b = true;
} }
} }
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,163 +1,163 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
The Software shall be used for Good, not Evil. The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
import java.util.Iterator; import java.util.Iterator;
/** /**
* Convert an HTTP header to a JSONObject and back. * Convert an HTTP header to a JSONObject and back.
* @author JSON.org * @author JSON.org
* @version 2010-12-24 * @version 2010-12-24
*/ */
public class HTTP { public class HTTP {
/** Carriage return/line feed. */ /** Carriage return/line feed. */
public static final String CRLF = "\r\n"; public static final String CRLF = "\r\n";
/** /**
* Convert an HTTP header string into a JSONObject. It can be a request * Convert an HTTP header string into a JSONObject. It can be a request
* header or a response header. A request header will contain * header or a response header. A request header will contain
* <pre>{ * <pre>{
* Method: "POST" (for example), * Method: "POST" (for example),
* "Request-URI": "/" (for example), * "Request-URI": "/" (for example),
* "HTTP-Version": "HTTP/1.1" (for example) * "HTTP-Version": "HTTP/1.1" (for example)
* }</pre> * }</pre>
* A response header will contain * A response header will contain
* <pre>{ * <pre>{
* "HTTP-Version": "HTTP/1.1" (for example), * "HTTP-Version": "HTTP/1.1" (for example),
* "Status-Code": "200" (for example), * "Status-Code": "200" (for example),
* "Reason-Phrase": "OK" (for example) * "Reason-Phrase": "OK" (for example)
* }</pre> * }</pre>
* In addition, the other parameters in the header will be captured, using * In addition, the other parameters in the header will be captured, using
* the HTTP field names as JSON names, so that <pre> * the HTTP field names as JSON names, so that <pre>
* Date: Sun, 26 May 2002 18:06:04 GMT * Date: Sun, 26 May 2002 18:06:04 GMT
* Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s * Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
* Cache-Control: no-cache</pre> * Cache-Control: no-cache</pre>
* become * become
* <pre>{... * <pre>{...
* Date: "Sun, 26 May 2002 18:06:04 GMT", * Date: "Sun, 26 May 2002 18:06:04 GMT",
* Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s", * Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
* "Cache-Control": "no-cache", * "Cache-Control": "no-cache",
* ...}</pre> * ...}</pre>
* It does no further checking or conversion. It does not parse dates. * It does no further checking or conversion. It does not parse dates.
* It does not do '%' transforms on URLs. * It does not do '%' transforms on URLs.
* @param string An HTTP header string. * @param string An HTTP header string.
* @return A JSONObject containing the elements and attributes * @return A JSONObject containing the elements and attributes
* of the XML string. * of the XML string.
* @throws JSONException * @throws JSONException
*/ */
public static JSONObject toJSONObject(String string) throws JSONException { public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
HTTPTokener x = new HTTPTokener(string); HTTPTokener x = new HTTPTokener(string);
String token; String token;
token = x.nextToken(); token = x.nextToken();
if (token.toUpperCase().startsWith("HTTP")) { if (token.toUpperCase().startsWith("HTTP")) {
// Response // Response
jo.put("HTTP-Version", token); jo.put("HTTP-Version", token);
jo.put("Status-Code", x.nextToken()); jo.put("Status-Code", x.nextToken());
jo.put("Reason-Phrase", x.nextTo('\0')); jo.put("Reason-Phrase", x.nextTo('\0'));
x.next(); x.next();
} else { } else {
// Request // Request
jo.put("Method", token); jo.put("Method", token);
jo.put("Request-URI", x.nextToken()); jo.put("Request-URI", x.nextToken());
jo.put("HTTP-Version", x.nextToken()); jo.put("HTTP-Version", x.nextToken());
} }
// Fields // Fields
while (x.more()) { while (x.more()) {
String name = x.nextTo(':'); String name = x.nextTo(':');
x.next(':'); x.next(':');
jo.put(name, x.nextTo('\0')); jo.put(name, x.nextTo('\0'));
x.next(); x.next();
} }
return jo; return jo;
} }
/** /**
* Convert a JSONObject into an HTTP header. A request header must contain * Convert a JSONObject into an HTTP header. A request header must contain
* <pre>{ * <pre>{
* Method: "POST" (for example), * Method: "POST" (for example),
* "Request-URI": "/" (for example), * "Request-URI": "/" (for example),
* "HTTP-Version": "HTTP/1.1" (for example) * "HTTP-Version": "HTTP/1.1" (for example)
* }</pre> * }</pre>
* A response header must contain * A response header must contain
* <pre>{ * <pre>{
* "HTTP-Version": "HTTP/1.1" (for example), * "HTTP-Version": "HTTP/1.1" (for example),
* "Status-Code": "200" (for example), * "Status-Code": "200" (for example),
* "Reason-Phrase": "OK" (for example) * "Reason-Phrase": "OK" (for example)
* }</pre> * }</pre>
* Any other members of the JSONObject will be output as HTTP fields. * Any other members of the JSONObject will be output as HTTP fields.
* The result will end with two CRLF pairs. * The result will end with two CRLF pairs.
* @param jo A JSONObject * @param jo A JSONObject
* @return An HTTP header string. * @return An HTTP header string.
* @throws JSONException if the object does not contain enough * @throws JSONException if the object does not contain enough
* information. * information.
*/ */
public static String toString(JSONObject jo) throws JSONException { public static String toString(JSONObject jo) throws JSONException {
Iterator keys = jo.keys(); Iterator keys = jo.keys();
String string; String string;
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (jo.has("Status-Code") && jo.has("Reason-Phrase")) { if (jo.has("Status-Code") && jo.has("Reason-Phrase")) {
sb.append(jo.getString("HTTP-Version")); sb.append(jo.getString("HTTP-Version"));
sb.append(' '); sb.append(' ');
sb.append(jo.getString("Status-Code")); sb.append(jo.getString("Status-Code"));
sb.append(' '); sb.append(' ');
sb.append(jo.getString("Reason-Phrase")); sb.append(jo.getString("Reason-Phrase"));
} else if (jo.has("Method") && jo.has("Request-URI")) { } else if (jo.has("Method") && jo.has("Request-URI")) {
sb.append(jo.getString("Method")); sb.append(jo.getString("Method"));
sb.append(' '); sb.append(' ');
sb.append('"'); sb.append('"');
sb.append(jo.getString("Request-URI")); sb.append(jo.getString("Request-URI"));
sb.append('"'); sb.append('"');
sb.append(' '); sb.append(' ');
sb.append(jo.getString("HTTP-Version")); sb.append(jo.getString("HTTP-Version"));
} else { } else {
throw new JSONException("Not enough material for an HTTP header."); throw new JSONException("Not enough material for an HTTP header.");
} }
sb.append(CRLF); sb.append(CRLF);
while (keys.hasNext()) { while (keys.hasNext()) {
string = keys.next().toString(); string = keys.next().toString();
if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) && if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) &&
!"Reason-Phrase".equals(string) && !"Method".equals(string) && !"Reason-Phrase".equals(string) && !"Method".equals(string) &&
!"Request-URI".equals(string) && !jo.isNull(string)) { !"Request-URI".equals(string) && !jo.isNull(string)) {
sb.append(string); sb.append(string);
sb.append(": "); sb.append(": ");
sb.append(jo.getString(string)); sb.append(jo.getString(string));
sb.append(CRLF); sb.append(CRLF);
} }
} }
sb.append(CRLF); sb.append(CRLF);
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,28 +1,28 @@
package org.json; package org.json;
/** /**
* The JSONException is thrown by the JSON.org classes when things are amiss. * The JSONException is thrown by the JSON.org classes when things are amiss.
* @author JSON.org * @author JSON.org
* @version 2010-12-24 * @version 2010-12-24
*/ */
public class JSONException extends Exception { public class JSONException extends Exception {
private static final long serialVersionUID = 0; private static final long serialVersionUID = 0;
private Throwable cause; private Throwable cause;
/** /**
* Constructs a JSONException with an explanatory message. * Constructs a JSONException with an explanatory message.
* @param message Detail about the reason for the exception. * @param message Detail about the reason for the exception.
*/ */
public JSONException(String message) { public JSONException(String message) {
super(message); super(message);
} }
public JSONException(Throwable cause) { public JSONException(Throwable cause) {
super(cause.getMessage()); super(cause.getMessage());
this.cause = cause; this.cause = cause;
} }
public Throwable getCause() { public Throwable getCause() {
return this.cause; return this.cause;
} }
} }

View File

@ -1,78 +1,78 @@
package org.json; package org.json;
/* /*
Copyright (c) 2006 JSON.org Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
The Software shall be used for Good, not Evil. The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
import java.io.StringWriter; import java.io.StringWriter;
/** /**
* JSONStringer provides a quick and convenient way of producing JSON text. * JSONStringer provides a quick and convenient way of producing JSON text.
* The texts produced strictly conform to JSON syntax rules. No whitespace is * The texts produced strictly conform to JSON syntax rules. No whitespace is
* added, so the results are ready for transmission or storage. Each instance of * added, so the results are ready for transmission or storage. Each instance of
* JSONStringer can produce one JSON text. * JSONStringer can produce one JSON text.
* <p> * <p>
* A JSONStringer instance provides a <code>value</code> method for appending * A JSONStringer instance provides a <code>value</code> method for appending
* values to the * values to the
* text, and a <code>key</code> * text, and a <code>key</code>
* method for adding keys before values in objects. There are <code>array</code> * method for adding keys before values in objects. There are <code>array</code>
* and <code>endArray</code> methods that make and bound array values, and * and <code>endArray</code> methods that make and bound array values, and
* <code>object</code> and <code>endObject</code> methods which make and bound * <code>object</code> and <code>endObject</code> methods which make and bound
* object values. All of these methods return the JSONWriter instance, * object values. All of these methods return the JSONWriter instance,
* permitting cascade style. For example, <pre> * permitting cascade style. For example, <pre>
* myString = new JSONStringer() * myString = new JSONStringer()
* .object() * .object()
* .key("JSON") * .key("JSON")
* .value("Hello, World!") * .value("Hello, World!")
* .endObject() * .endObject()
* .toString();</pre> which produces the string <pre> * .toString();</pre> which produces the string <pre>
* {"JSON":"Hello, World!"}</pre> * {"JSON":"Hello, World!"}</pre>
* <p> * <p>
* The first method called must be <code>array</code> or <code>object</code>. * The first method called must be <code>array</code> or <code>object</code>.
* There are no methods for adding commas or colons. JSONStringer adds them for * There are no methods for adding commas or colons. JSONStringer adds them for
* you. Objects and arrays can be nested up to 20 levels deep. * you. Objects and arrays can be nested up to 20 levels deep.
* <p> * <p>
* This can sometimes be easier than using a JSONObject to build a string. * This can sometimes be easier than using a JSONObject to build a string.
* @author JSON.org * @author JSON.org
* @version 2008-09-18 * @version 2008-09-18
*/ */
public class JSONStringer extends JSONWriter { public class JSONStringer extends JSONWriter {
/** /**
* Make a fresh JSONStringer. It can be used to build one JSON text. * Make a fresh JSONStringer. It can be used to build one JSON text.
*/ */
public JSONStringer() { public JSONStringer() {
super(new StringWriter()); super(new StringWriter());
} }
/** /**
* Return the JSON text. This method is used to obtain the product of the * Return the JSON text. This method is used to obtain the product of the
* JSONStringer instance. It will return <code>null</code> if there was a * JSONStringer instance. It will return <code>null</code> if there was a
* problem in the construction of the JSON text (such as the calls to * problem in the construction of the JSON text (such as the calls to
* <code>array</code> were not properly balanced with calls to * <code>array</code> were not properly balanced with calls to
* <code>endArray</code>). * <code>endArray</code>).
* @return The JSON text. * @return The JSON text.
*/ */
public String toString() { public String toString() {
return this.mode == 'd' ? this.writer.toString() : null; return this.mode == 'd' ? this.writer.toString() : null;
} }
} }

View File

@ -1,327 +1,327 @@
package org.json; package org.json;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
/* /*
Copyright (c) 2006 JSON.org Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
The Software shall be used for Good, not Evil. The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
/** /**
* JSONWriter provides a quick and convenient way of producing JSON text. * JSONWriter provides a quick and convenient way of producing JSON text.
* The texts produced strictly conform to JSON syntax rules. No whitespace is * The texts produced strictly conform to JSON syntax rules. No whitespace is
* added, so the results are ready for transmission or storage. Each instance of * added, so the results are ready for transmission or storage. Each instance of
* JSONWriter can produce one JSON text. * JSONWriter can produce one JSON text.
* <p> * <p>
* A JSONWriter instance provides a <code>value</code> method for appending * A JSONWriter instance provides a <code>value</code> method for appending
* values to the * values to the
* text, and a <code>key</code> * text, and a <code>key</code>
* method for adding keys before values in objects. There are <code>array</code> * method for adding keys before values in objects. There are <code>array</code>
* and <code>endArray</code> methods that make and bound array values, and * and <code>endArray</code> methods that make and bound array values, and
* <code>object</code> and <code>endObject</code> methods which make and bound * <code>object</code> and <code>endObject</code> methods which make and bound
* object values. All of these methods return the JSONWriter instance, * object values. All of these methods return the JSONWriter instance,
* permitting a cascade style. For example, <pre> * permitting a cascade style. For example, <pre>
* new JSONWriter(myWriter) * new JSONWriter(myWriter)
* .object() * .object()
* .key("JSON") * .key("JSON")
* .value("Hello, World!") * .value("Hello, World!")
* .endObject();</pre> which writes <pre> * .endObject();</pre> which writes <pre>
* {"JSON":"Hello, World!"}</pre> * {"JSON":"Hello, World!"}</pre>
* <p> * <p>
* The first method called must be <code>array</code> or <code>object</code>. * The first method called must be <code>array</code> or <code>object</code>.
* There are no methods for adding commas or colons. JSONWriter adds them for * There are no methods for adding commas or colons. JSONWriter adds them for
* you. Objects and arrays can be nested up to 20 levels deep. * you. Objects and arrays can be nested up to 20 levels deep.
* <p> * <p>
* This can sometimes be easier than using a JSONObject to build a string. * This can sometimes be easier than using a JSONObject to build a string.
* @author JSON.org * @author JSON.org
* @version 2011-11-24 * @version 2011-11-24
*/ */
public class JSONWriter { public class JSONWriter {
private static final int maxdepth = 200; private static final int maxdepth = 200;
/** /**
* The comma flag determines if a comma should be output before the next * The comma flag determines if a comma should be output before the next
* value. * value.
*/ */
private boolean comma; private boolean comma;
/** /**
* The current mode. Values: * The current mode. Values:
* 'a' (array), * 'a' (array),
* 'd' (done), * 'd' (done),
* 'i' (initial), * 'i' (initial),
* 'k' (key), * 'k' (key),
* 'o' (object). * 'o' (object).
*/ */
protected char mode; protected char mode;
/** /**
* The object/array stack. * The object/array stack.
*/ */
private final JSONObject stack[]; private final JSONObject stack[];
/** /**
* The stack top index. A value of 0 indicates that the stack is empty. * The stack top index. A value of 0 indicates that the stack is empty.
*/ */
private int top; private int top;
/** /**
* The writer that will receive the output. * The writer that will receive the output.
*/ */
protected Writer writer; protected Writer writer;
/** /**
* Make a fresh JSONWriter. It can be used to build one JSON text. * Make a fresh JSONWriter. It can be used to build one JSON text.
*/ */
public JSONWriter(Writer w) { public JSONWriter(Writer w) {
this.comma = false; this.comma = false;
this.mode = 'i'; this.mode = 'i';
this.stack = new JSONObject[maxdepth]; this.stack = new JSONObject[maxdepth];
this.top = 0; this.top = 0;
this.writer = w; this.writer = w;
} }
/** /**
* Append a value. * Append a value.
* @param string A string value. * @param string A string value.
* @return this * @return this
* @throws JSONException If the value is out of sequence. * @throws JSONException If the value is out of sequence.
*/ */
private JSONWriter append(String string) throws JSONException { private JSONWriter append(String string) throws JSONException {
if (string == null) { if (string == null) {
throw new JSONException("Null pointer"); throw new JSONException("Null pointer");
} }
if (this.mode == 'o' || this.mode == 'a') { if (this.mode == 'o' || this.mode == 'a') {
try { try {
if (this.comma && this.mode == 'a') { if (this.comma && this.mode == 'a') {
this.writer.write(','); this.writer.write(',');
} }
this.writer.write(string); this.writer.write(string);
} catch (IOException e) { } catch (IOException e) {
throw new JSONException(e); throw new JSONException(e);
} }
if (this.mode == 'o') { if (this.mode == 'o') {
this.mode = 'k'; this.mode = 'k';
} }
this.comma = true; this.comma = true;
return this; return this;
} }
throw new JSONException("Value out of sequence."); throw new JSONException("Value out of sequence.");
} }
/** /**
* Begin appending a new array. All values until the balancing * Begin appending a new array. All values until the balancing
* <code>endArray</code> will be appended to this array. The * <code>endArray</code> will be appended to this array. The
* <code>endArray</code> method must be called to mark the array's end. * <code>endArray</code> method must be called to mark the array's end.
* @return this * @return this
* @throws JSONException If the nesting is too deep, or if the object is * @throws JSONException If the nesting is too deep, or if the object is
* started in the wrong place (for example as a key or after the end of the * started in the wrong place (for example as a key or after the end of the
* outermost array or object). * outermost array or object).
*/ */
public JSONWriter array() throws JSONException { public JSONWriter array() throws JSONException {
if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
this.push(null); this.push(null);
this.append("["); this.append("[");
this.comma = false; this.comma = false;
return this; return this;
} }
throw new JSONException("Misplaced array."); throw new JSONException("Misplaced array.");
} }
/** /**
* End something. * End something.
* @param mode Mode * @param mode Mode
* @param c Closing character * @param c Closing character
* @return this * @return this
* @throws JSONException If unbalanced. * @throws JSONException If unbalanced.
*/ */
private JSONWriter end(char mode, char c) throws JSONException { private JSONWriter end(char mode, char c) throws JSONException {
if (this.mode != mode) { if (this.mode != mode) {
throw new JSONException(mode == 'a' throw new JSONException(mode == 'a'
? "Misplaced endArray." ? "Misplaced endArray."
: "Misplaced endObject."); : "Misplaced endObject.");
} }
this.pop(mode); this.pop(mode);
try { try {
this.writer.write(c); this.writer.write(c);
} catch (IOException e) { } catch (IOException e) {
throw new JSONException(e); throw new JSONException(e);
} }
this.comma = true; this.comma = true;
return this; return this;
} }
/** /**
* End an array. This method most be called to balance calls to * End an array. This method most be called to balance calls to
* <code>array</code>. * <code>array</code>.
* @return this * @return this
* @throws JSONException If incorrectly nested. * @throws JSONException If incorrectly nested.
*/ */
public JSONWriter endArray() throws JSONException { public JSONWriter endArray() throws JSONException {
return this.end('a', ']'); return this.end('a', ']');
} }
/** /**
* End an object. This method most be called to balance calls to * End an object. This method most be called to balance calls to
* <code>object</code>. * <code>object</code>.
* @return this * @return this
* @throws JSONException If incorrectly nested. * @throws JSONException If incorrectly nested.
*/ */
public JSONWriter endObject() throws JSONException { public JSONWriter endObject() throws JSONException {
return this.end('k', '}'); return this.end('k', '}');
} }
/** /**
* Append a key. The key will be associated with the next value. In an * Append a key. The key will be associated with the next value. In an
* object, every value must be preceded by a key. * object, every value must be preceded by a key.
* @param string A key string. * @param string A key string.
* @return this * @return this
* @throws JSONException If the key is out of place. For example, keys * @throws JSONException If the key is out of place. For example, keys
* do not belong in arrays or if the key is null. * do not belong in arrays or if the key is null.
*/ */
public JSONWriter key(String string) throws JSONException { public JSONWriter key(String string) throws JSONException {
if (string == null) { if (string == null) {
throw new JSONException("Null key."); throw new JSONException("Null key.");
} }
if (this.mode == 'k') { if (this.mode == 'k') {
try { try {
this.stack[this.top - 1].putOnce(string, Boolean.TRUE); this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
if (this.comma) { if (this.comma) {
this.writer.write(','); this.writer.write(',');
} }
this.writer.write(JSONObject.quote(string)); this.writer.write(JSONObject.quote(string));
this.writer.write(':'); this.writer.write(':');
this.comma = false; this.comma = false;
this.mode = 'o'; this.mode = 'o';
return this; return this;
} catch (IOException e) { } catch (IOException e) {
throw new JSONException(e); throw new JSONException(e);
} }
} }
throw new JSONException("Misplaced key."); throw new JSONException("Misplaced key.");
} }
/** /**
* Begin appending a new object. All keys and values until the balancing * Begin appending a new object. All keys and values until the balancing
* <code>endObject</code> will be appended to this object. The * <code>endObject</code> will be appended to this object. The
* <code>endObject</code> method must be called to mark the object's end. * <code>endObject</code> method must be called to mark the object's end.
* @return this * @return this
* @throws JSONException If the nesting is too deep, or if the object is * @throws JSONException If the nesting is too deep, or if the object is
* started in the wrong place (for example as a key or after the end of the * started in the wrong place (for example as a key or after the end of the
* outermost array or object). * outermost array or object).
*/ */
public JSONWriter object() throws JSONException { public JSONWriter object() throws JSONException {
if (this.mode == 'i') { if (this.mode == 'i') {
this.mode = 'o'; this.mode = 'o';
} }
if (this.mode == 'o' || this.mode == 'a') { if (this.mode == 'o' || this.mode == 'a') {
this.append("{"); this.append("{");
this.push(new JSONObject()); this.push(new JSONObject());
this.comma = false; this.comma = false;
return this; return this;
} }
throw new JSONException("Misplaced object."); throw new JSONException("Misplaced object.");
} }
/** /**
* Pop an array or object scope. * Pop an array or object scope.
* @param c The scope to close. * @param c The scope to close.
* @throws JSONException If nesting is wrong. * @throws JSONException If nesting is wrong.
*/ */
private void pop(char c) throws JSONException { private void pop(char c) throws JSONException {
if (this.top <= 0) { if (this.top <= 0) {
throw new JSONException("Nesting error."); throw new JSONException("Nesting error.");
} }
char m = this.stack[this.top - 1] == null ? 'a' : 'k'; char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) { if (m != c) {
throw new JSONException("Nesting error."); throw new JSONException("Nesting error.");
} }
this.top -= 1; this.top -= 1;
this.mode = this.top == 0 this.mode = this.top == 0
? 'd' ? 'd'
: this.stack[this.top - 1] == null : this.stack[this.top - 1] == null
? 'a' ? 'a'
: 'k'; : 'k';
} }
/** /**
* Push an array or object scope. * Push an array or object scope.
* @param c The scope to open. * @param c The scope to open.
* @throws JSONException If nesting is too deep. * @throws JSONException If nesting is too deep.
*/ */
private void push(JSONObject jo) throws JSONException { private void push(JSONObject jo) throws JSONException {
if (this.top >= maxdepth) { if (this.top >= maxdepth) {
throw new JSONException("Nesting too deep."); throw new JSONException("Nesting too deep.");
} }
this.stack[this.top] = jo; this.stack[this.top] = jo;
this.mode = jo == null ? 'a' : 'k'; this.mode = jo == null ? 'a' : 'k';
this.top += 1; this.top += 1;
} }
/** /**
* Append either the value <code>true</code> or the value * Append either the value <code>true</code> or the value
* <code>false</code>. * <code>false</code>.
* @param b A boolean. * @param b A boolean.
* @return this * @return this
* @throws JSONException * @throws JSONException
*/ */
public JSONWriter value(boolean b) throws JSONException { public JSONWriter value(boolean b) throws JSONException {
return this.append(b ? "true" : "false"); return this.append(b ? "true" : "false");
} }
/** /**
* Append a double value. * Append a double value.
* @param d A double. * @param d A double.
* @return this * @return this
* @throws JSONException If the number is not finite. * @throws JSONException If the number is not finite.
*/ */
public JSONWriter value(double d) throws JSONException { public JSONWriter value(double d) throws JSONException {
return this.value(new Double(d)); return this.value(new Double(d));
} }
/** /**
* Append a long value. * Append a long value.
* @param l A long. * @param l A long.
* @return this * @return this
* @throws JSONException * @throws JSONException
*/ */
public JSONWriter value(long l) throws JSONException { public JSONWriter value(long l) throws JSONException {
return this.append(Long.toString(l)); return this.append(Long.toString(l));
} }
/** /**
* Append an object value. * Append an object value.
* @param object The object to append. It can be null, or a Boolean, Number, * @param object The object to append. It can be null, or a Boolean, Number,
* String, JSONObject, or JSONArray, or an object that implements JSONString. * String, JSONObject, or JSONArray, or an object that implements JSONString.
* @return this * @return this
* @throws JSONException If the value is out of sequence. * @throws JSONException If the value is out of sequence.
*/ */
public JSONWriter value(Object object) throws JSONException { public JSONWriter value(Object object) throws JSONException {
return this.append(JSONObject.valueToString(object)); return this.append(JSONObject.valueToString(object));
} }
} }

View File

@ -1,13 +1,13 @@
name: Quake name: Quake
authors: [Geekpower14, Bl4ckSkull666] authors: [Geekpower14, Bl4ckSkull666, AlkorZ3]
main: com.Geekpower14.Quake.Quake main: com.Geekpower14.Quake.Quake
version: 3.4.0 version: 3.5.0
api-version: 1.14 api-version: 1.16
depend: [WorldEdit,Vault] depend: [WorldEdit,Vault]
softdepend: [Multiverse-Core] softdepend: [Multiverse-Core]
website: https://www.survival-piraten.de website: https://obsidia.rx3.net
commands: commands:
quake: quake:
description: Quake command description: Quake command
usage: /quake usage: /quake
aliases: [q] aliases: [q]