mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37c5fca2ab |
-25
@@ -1,25 +0,0 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
# Mac filesystem dust
|
||||
/.DS_Store
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,56 @@
|
||||
<project name="dynmap" default="dist" basedir=".">
|
||||
<!-- Change the following two properties to the correct jar files -->
|
||||
<property name="minecraftserver.jar" location="../../minecraft_server.jar"/>
|
||||
<property name="hmod.jar" location="../../Minecraft_Mod.jar"/>
|
||||
|
||||
<property name="minecraft" location="../../"/>
|
||||
<property name="plugins" location="${minecraft}/plugins/"/>
|
||||
<property name="http_root" location="/srv/http/dynmap/"/>
|
||||
|
||||
<property name="src" location="src"/>
|
||||
<property name="bin" location="bin"/>
|
||||
<property name="dist" location="dist"/>
|
||||
<property name="web" location="web"/>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${bin}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init">
|
||||
<javac srcdir="${src}" destdir="${bin}" includeantruntime="false">
|
||||
<classpath>
|
||||
<pathelement location="${hmod.jar}"/>
|
||||
<pathelement location="${minecraftserver.jar}"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="compile">
|
||||
<mkdir dir="${dist}"/>
|
||||
<jar jarfile="${dist}/map.jar" basedir="${bin}"/>
|
||||
</target>
|
||||
|
||||
<target name="deploy" depends="dist">
|
||||
<copy file="${dist}/map.jar" todir="${plugins}"/>
|
||||
<copy file="colors.txt" todir="${minecraft}"/>
|
||||
<copy todir="${http_root}">
|
||||
<fileset dir="web"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="release" depends="dist">
|
||||
<delete file="dynmap.zip"/>
|
||||
<zip destfile="dynmap.zip">
|
||||
<zipfileset dir="." includes="README.md" fullpath="readme.txt"/>
|
||||
<zipfileset dir="." includes="build.xml"/>
|
||||
<zipfileset dir="${dist}" includes="*.jar"/>
|
||||
<zipfileset dir="${src}" includes="*.java" prefix="src/"/>
|
||||
<zipfileset dir="${web}" includes="**" prefix="web/"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin}"/>
|
||||
<delete dir="${dist}"/>
|
||||
</target>
|
||||
</project>
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
1 120 120 120 255 96 96 96 255 60 60 60 255 48 48 48 255
|
||||
2 117 176 73 255 93 140 58 255 58 88 36 255 46 70 29 255
|
||||
3 134 96 67 255 107 76 53 255 67 48 33 255 53 38 26 255
|
||||
4 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
|
||||
48 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
|
||||
5 157 128 79 255 125 102 63 255 78 64 39 255 62 51 31 255
|
||||
6 120 120 120 0 96 96 96 0 60 60 60 0 48 48 48 0
|
||||
7 84 84 84 255 67 67 67 255 42 42 42 255 33 33 33 255
|
||||
8 38 92 255 51 30 73 204 51 19 46 127 51 15 36 102 51
|
||||
9 38 92 255 51 30 73 204 51 19 46 127 51 15 36 102 51
|
||||
10 255 90 0 255 204 72 0 255 127 45 0 255 102 36 0 255
|
||||
11 255 90 0 255 204 72 0 255 127 45 0 255 102 36 0 255
|
||||
12 218 210 158 255 174 168 126 255 109 105 79 255 87 84 63 255
|
||||
13 136 126 126 255 108 100 100 255 68 63 63 255 54 50 50 255
|
||||
14 143 140 125 255 114 112 100 255 71 70 62 255 57 56 50 255
|
||||
15 136 130 127 255 108 104 101 255 68 65 63 255 54 52 50 255
|
||||
16 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
|
||||
17 102 81 51 255 81 64 40 255 51 40 25 255 40 32 20 255
|
||||
18 60 192 41 100 48 153 32 100 30 96 20 100 24 76 16 100
|
||||
20 255 255 255 64 204 204 204 64 127 127 127 64 102 102 102 64
|
||||
35 222 222 222 255 177 177 177 255 111 111 111 255 88 88 88 255
|
||||
37 255 0 0 255 204 0 0 255 127 0 0 255 102 0 0 255
|
||||
38 255 255 0 0 204 204 0 0 127 127 0 0 102 102 0 0
|
||||
41 232 245 46 255 185 196 36 255 116 122 23 255 92 98 18 255
|
||||
42 191 191 191 255 152 152 152 255 95 95 95 255 76 76 76 255
|
||||
43 200 200 200 255 160 160 160 255 100 100 100 255 80 80 80 255
|
||||
44 200 200 200 255 160 160 160 255 100 100 100 255 80 80 80 255
|
||||
45 170 86 62 255 136 68 49 255 85 43 31 255 68 34 24 255
|
||||
46 160 83 65 255 128 66 52 255 80 41 32 255 64 33 26 255
|
||||
49 26 11 43 255 20 8 34 255 13 5 21 255 10 4 17 255
|
||||
51 255 170 30 200 204 136 24 200 127 85 15 200 102 68 12 200
|
||||
53 157 128 79 255 125 102 63 255 78 64 39 255 62 51 31 255
|
||||
54 125 91 38 255 100 72 30 255 62 45 19 255 50 36 15 255
|
||||
56 129 140 143 255 103 112 114 255 64 70 71 255 51 56 57 255
|
||||
57 45 166 152 255 36 132 121 255 22 83 76 255 18 66 60 255
|
||||
58 114 88 56 255 91 70 44 255 57 44 28 255 45 35 22 255
|
||||
59 146 192 0 255 116 153 0 255 73 96 0 255 58 76 0 255
|
||||
60 95 58 30 255 76 46 24 255 47 29 15 255 38 23 12 255
|
||||
61 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255
|
||||
62 96 96 96 255 76 76 76 255 48 48 48 255 38 38 38 255
|
||||
63 111 91 54 255 88 72 43 255 55 45 27 255 44 36 21 255
|
||||
64 136 109 67 255 108 87 53 255 68 54 33 255 54 43 26 255
|
||||
65 181 140 64 32 144 112 51 32 90 70 32 32 72 56 25 32
|
||||
66 150 134 102 180 120 107 81 180 75 67 51 180 60 53 40 180
|
||||
67 115 115 115 255 92 92 92 255 57 57 57 255 46 46 46 255
|
||||
71 191 191 191 255 152 152 152 255 95 95 95 255 76 76 76 255
|
||||
73 131 107 107 255 104 85 85 255 65 53 53 255 52 42 42 255
|
||||
74 131 107 107 255 104 85 85 255 65 53 53 255 52 42 42 255
|
||||
78 255 255 255 255 204 204 204 255 127 127 127 255 102 102 102 255
|
||||
79 83 113 163 51 66 90 130 51 41 56 81 51 33 45 65 51
|
||||
80 250 250 250 255 200 200 200 255 125 125 125 255 100 100 100 255
|
||||
81 25 120 25 255 20 96 20 255 12 60 12 255 10 48 10 255
|
||||
82 151 157 169 255 120 125 135 255 75 78 84 255 60 62 67 255
|
||||
83 193 234 150 255 154 187 120 255 96 117 75 255 77 93 60 255
|
||||
|
||||
redstone torch off
|
||||
75 159 127 80 255 72 56 25 0 181 140 64 255 144 112 51 0
|
||||
redstone torch on
|
||||
76 159 127 80 255 102 0 0 0 255 0 0 255 204 0 0 0
|
||||
torch
|
||||
50 159 127 80 255 98 88 20 0 245 220 50 255 196 176 40 0
|
||||
|
||||
fence
|
||||
85 172 136 82 255 172 136 82 0 91 70 37 255 91 70 37 0
|
||||
netherstone
|
||||
87 166 89 89 255 141 80 62 255 135 15 15 255 96 6 6 255
|
||||
slowsand
|
||||
88 133 109 94 255 121 97 82 255 90 70 57 255 79 59 46 255
|
||||
lightstone
|
||||
89 249 212 156 255 255 188 94 255 192 143 70 255 122 91 44 255
|
||||
portal
|
||||
90 99 66 222 128 99 66 222 128 99 66 222 128 99 66 222 128
|
||||
@@ -1,166 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<BUILD_NUMBER>Dev${timestamp}</BUILD_NUMBER>
|
||||
</properties>
|
||||
<url>http://github.com/webbukkit/dynmap/</url>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/webbukkit/dynmap/issues</url>
|
||||
</issueManagement>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
<include>*.txt</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<excludes>
|
||||
<exclude>*.yml</exclude>
|
||||
<exclude>*.txt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>us.dynmap:dynmap-api:jar:*</include>
|
||||
<include>us.dynmap:DynmapCore:jar:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<releases>
|
||||
</releases>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<releases>
|
||||
</releases>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
<id>dynmap-repo</id>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.bukkit</groupId>
|
||||
<artifactId>Permissions</artifactId>
|
||||
<version>3.1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.7-R1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>DynmapCore</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.19.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco</groupId>
|
||||
<artifactId>bPermissions</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platymuus.bukkit.permissions</groupId>
|
||||
<artifactId>PermissionsBukkit</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.anjocaido</groupId>
|
||||
<artifactId>EssentialsGroupManager</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>1.9.4</version>
|
||||
</project>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
Commands
|
||||
--------------------------------------------------
|
||||
/map_wait [wait] - set wait between tile renders (ms)
|
||||
/map_stat - query number of tiles in render queue
|
||||
/map_regen - regenerate entire map (currently buggy)
|
||||
/map_debug - send map debugging messages
|
||||
/map_nodebug - disable map debugging messages
|
||||
/map_regenzoom - regenerates zoom-out tiles
|
||||
|
||||
/addsign [name] - adds a named sign to the map
|
||||
/removesign [name] - removes a named sign to the map
|
||||
/listsigns - list all named signs
|
||||
/tpsign [name] - teleport to a named sign
|
||||
|
||||
server.properties
|
||||
--------------------------------------------------
|
||||
map-colorsetpath - point to colors.txt
|
||||
map-tilepath - point to web/tiles folder
|
||||
map-signspath - point to signs.txt file (do not need to create the file, one will be created when you create a sign)
|
||||
map-serverport - the port the web server runs on (default is 8123)
|
||||
map-showmarkers - a list of which markers to show on the map, comma separated if multiple (spawn, homes, warps, signs, players, all, none)
|
||||
map-generateportraits - whether player-portraits are generated by the server (0, 1, default: 0)
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Cache<K, V>
|
||||
{
|
||||
private final int size;
|
||||
private int len;
|
||||
|
||||
private CacheNode head;
|
||||
private CacheNode tail;
|
||||
|
||||
private class CacheNode
|
||||
{
|
||||
public CacheNode prev;
|
||||
public CacheNode next;
|
||||
public K key;
|
||||
public V value;
|
||||
|
||||
public CacheNode(K key, V value)
|
||||
{
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
prev = null;
|
||||
next = null;
|
||||
}
|
||||
|
||||
public void unlink()
|
||||
{
|
||||
if(prev == null) {
|
||||
head = next;
|
||||
} else {
|
||||
prev.next = next;
|
||||
}
|
||||
|
||||
if(next == null) {
|
||||
tail = prev;
|
||||
} else {
|
||||
next.prev = prev;
|
||||
}
|
||||
|
||||
prev = null;
|
||||
next = null;
|
||||
|
||||
len --;
|
||||
}
|
||||
|
||||
public void append()
|
||||
{
|
||||
if(tail == null) {
|
||||
head = this;
|
||||
tail = this;
|
||||
} else {
|
||||
tail.next = this;
|
||||
prev = tail;
|
||||
tail = this;
|
||||
}
|
||||
|
||||
len ++;
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<K, CacheNode> map;
|
||||
|
||||
public Cache(int size)
|
||||
{
|
||||
this.size = size;
|
||||
len = 0;
|
||||
|
||||
head = null;
|
||||
tail = null;
|
||||
|
||||
map = new HashMap<K, CacheNode>();
|
||||
}
|
||||
|
||||
/* returns value for key, if key exists in the cache
|
||||
* otherwise null */
|
||||
public V get(K key)
|
||||
{
|
||||
CacheNode n = map.get(key);
|
||||
if(n == null)
|
||||
return null;
|
||||
return n.value;
|
||||
}
|
||||
|
||||
/* puts a new key-value pair in the cache
|
||||
* if the key existed already, the value is updated, and the old value is returned
|
||||
* if the key didn't exist, it is added; the oldest value (now pushed out of the
|
||||
* cache) may be returned, or null if the cache isn't yet full */
|
||||
public V put(K key, V value)
|
||||
{
|
||||
CacheNode n = map.get(key);
|
||||
if(n == null) {
|
||||
V ret = null;
|
||||
|
||||
if(len >= size) {
|
||||
CacheNode first = head;
|
||||
first.unlink();
|
||||
map.remove(first.key);
|
||||
ret = first.value;
|
||||
}
|
||||
|
||||
CacheNode add = new CacheNode(key, value);
|
||||
add.append();
|
||||
map.put(key, add);
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
n.unlink();
|
||||
V old = n.value;
|
||||
n.value = value;
|
||||
n.append();
|
||||
return old;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/* FlatFileSource class wrapper to expose protected properties */
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DMFlatFileSource extends FlatFileSource {
|
||||
public List<Warp> getAllWarps() {
|
||||
return this.warps;
|
||||
}
|
||||
|
||||
public List<Warp> getAllHomes() {
|
||||
return this.homes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/* MySQLSource class wrapper to expose protected properties */
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DMMySQLSource extends MySQLSource {
|
||||
public List<Warp> getAllWarps() {
|
||||
return this.warps;
|
||||
}
|
||||
|
||||
public List<Warp> getAllHomes() {
|
||||
return this.homes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MapListener extends PluginListener {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private MapManager mgr;
|
||||
|
||||
public MapListener(MapManager mgr)
|
||||
{
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand)
|
||||
{
|
||||
if(blockPlaced == null) {
|
||||
mgr.debug(player.getName() + " touched a null block");
|
||||
return false;
|
||||
}
|
||||
if(mgr.touch(blockPlaced.getX(), blockPlaced.getY(), blockPlaced.getZ()))
|
||||
mgr.debug(player.getName() + " touch " + blockPlaced.getX() + "," + blockPlaced.getY() + "," + blockPlaced.getZ() + " from onBlockCreate");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroy(Player player, Block block)
|
||||
{
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
if(x == 0 && y == 0 && z == 0)
|
||||
return false;
|
||||
|
||||
if(mgr.touch(x, y, z))
|
||||
mgr.debug(player.getName() + " touch " + x + "," + y + "," + z + " from onBlockBreak");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLogin(Player player)
|
||||
{
|
||||
mgr.getPlayerImage(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(Player player, String[] split)
|
||||
{
|
||||
if(!player.canUseCommand(split[0]))
|
||||
return false;
|
||||
|
||||
if(split[0].equals("/map_wait")) {
|
||||
if(split.length < 2) {
|
||||
mgr.renderWait = 1000;
|
||||
} else {
|
||||
try {
|
||||
mgr.renderWait = Integer.parseInt(split[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
player.sendMessage(Colors.Rose + "Invalid number");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/map_regen")) {
|
||||
mgr.regenerate((int) player.getX(), (int) player.getY(), (int) player.getZ());
|
||||
player.sendMessage(Colors.Rose + "Map regeneration in progress");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/map_stat")) {
|
||||
player.sendMessage(Colors.Rose + "Stale tiles: " + mgr.getStaleCount() + " Recent updates: " + mgr.getRecentUpdateCount());
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/map_debug")) {
|
||||
mgr.debugPlayer = player.getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/map_nodebug")) {
|
||||
mgr.debugPlayer = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/addsign")) {
|
||||
if(split.length < 2)
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /addsign [name]");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mgr.addSign(player, split[1], player.getX(), player.getY(), player.getZ()))
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" added successfully");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/removesign")) {
|
||||
if(split.length < 2)
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /removesign [name]");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mgr.removeSign(player, split[1]))
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" removed successfully");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/listsigns")) {
|
||||
String msg = "";
|
||||
Collection<Warp> values = mgr.signs.values();
|
||||
Iterator<Warp> it = values.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Warp sign = it.next();
|
||||
String line = " - " + sign.Name + "\t";
|
||||
msg += line;
|
||||
}
|
||||
player.sendMessage("" + Colors.White + msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/tpsign")) {
|
||||
if(split.length < 2)
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /tpsign [name]");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mgr.teleportToSign(player, split[1]))
|
||||
{
|
||||
//player.sendMessage("Map> " + Colors.White + "");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/map_regenzoom")) {
|
||||
mgr.regenerateZoom((int) player.getX(), (int) player.getY(), (int) player.getZ());
|
||||
player.sendMessage(Colors.Rose + "regenerateZoom done");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
/* this class stores a tile update */
|
||||
|
||||
public class TileUpdate {
|
||||
public long at;
|
||||
public MapTile tile;
|
||||
|
||||
public TileUpdate(long at, MapTile tile)
|
||||
{
|
||||
this.at = at;
|
||||
this.tile = tile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class WebServer extends Thread {
|
||||
|
||||
public static final String VERSION = "Huncraft";
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private ServerSocket sock = null;
|
||||
private boolean running = false;
|
||||
|
||||
private MapManager mgr;
|
||||
|
||||
public WebServer(int port, MapManager mgr) throws IOException
|
||||
{
|
||||
this.mgr = mgr;
|
||||
sock = new ServerSocket(port, 5, InetAddress.getByName("127.0.0.1"));
|
||||
running = true;
|
||||
start();
|
||||
log.info("map WebServer started on port " + port);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while (running) {
|
||||
try {
|
||||
Socket socket = sock.accept();
|
||||
WebServerRequest requestThread = new WebServerRequest(socket, mgr);
|
||||
requestThread.start();
|
||||
}
|
||||
catch (IOException e) {
|
||||
log.info("map WebServer.run() stops with IOException");
|
||||
break;
|
||||
}
|
||||
}
|
||||
log.info("map WebServer run() exiting");
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
try {
|
||||
if(sock != null) {
|
||||
sock.close();
|
||||
}
|
||||
} catch(IOException e) {
|
||||
log.info("map stop() got IOException while closing socket");
|
||||
}
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class WebServerRequest extends Thread {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private Socket sock;
|
||||
private MapManager mgr;
|
||||
|
||||
public WebServerRequest(Socket socket, MapManager mgr)
|
||||
{
|
||||
sock = socket;
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
private static void sendHeader(BufferedOutputStream out, int code, String contentType, long contentLength, long lastModified) throws IOException
|
||||
{
|
||||
out.write(("HTTP/1.0 " + code + " OK\r\n" +
|
||||
"Date: " + new Date().toString() + "\r\n" +
|
||||
"Server: JibbleWebServer/1.0\r\n" +
|
||||
"Content-Type: " + contentType + "\r\n" +
|
||||
"Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n" +
|
||||
((contentLength != -1) ? "Content-Length: " + contentLength + "\r\n" : "") +
|
||||
"Last-modified: " + new Date(lastModified).toString() + "\r\n" +
|
||||
"\r\n").getBytes());
|
||||
}
|
||||
|
||||
private static void sendError(BufferedOutputStream out, int code, String message) throws IOException
|
||||
{
|
||||
message = message + "<hr>" + WebServer.VERSION;
|
||||
sendHeader(out, code, "text/html", message.length(), System.currentTimeMillis());
|
||||
out.write(message.getBytes());
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
InputStream reader = null;
|
||||
try {
|
||||
sock.setSoTimeout(30000);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
|
||||
BufferedOutputStream out = new BufferedOutputStream(sock.getOutputStream());
|
||||
|
||||
String request = in.readLine();
|
||||
if (request == null || !request.startsWith("GET ") || !(request.endsWith(" HTTP/1.0") || request.endsWith("HTTP/1.1"))) {
|
||||
// Invalid request type (no "GET")
|
||||
sendError(out, 500, "Invalid Method.");
|
||||
return;
|
||||
}
|
||||
|
||||
String path = request.substring(4, request.length() - 9);
|
||||
|
||||
int current = (int) (System.currentTimeMillis() / 1000);
|
||||
long cutoff = 0;
|
||||
|
||||
if(path.charAt(0) == '/') {
|
||||
try {
|
||||
cutoff = ((long) Integer.parseInt(path.substring(1))) * 1000;
|
||||
} catch(NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
sendHeader(out, 200, "text/plain", -1, System.currentTimeMillis());
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(current + " " + etc.getServer().getRelativeTime() + "\n");
|
||||
|
||||
if (mgr.showPlayers) {
|
||||
for(Player player : etc.getServer().getPlayerList()) {
|
||||
sb.append(player.getName() + " player " + player.getX() + " " + player.getY() + " " + player.getZ() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (mgr.showSigns) {
|
||||
for(Warp sign : mgr.signs.values())
|
||||
{
|
||||
sb.append(sign.Name + " sign " + sign.Location.x + " " + sign.Location.y + " " + sign.Location.z + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (mgr.showWarps) {
|
||||
List<Warp> warps = mgr.loadWarps();
|
||||
|
||||
if (warps != null) {
|
||||
for(Warp warp : warps) {
|
||||
sb.append(warp.Name + " warp " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mgr.showHomes) {
|
||||
List<Warp> homes = mgr.loadHomes();
|
||||
|
||||
if (homes != null) {
|
||||
for(Warp warp : homes) {
|
||||
sb.append(warp.Name + " home " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mgr.showSpawn) {
|
||||
Location spawnLocation = etc.getServer().getSpawnLocation();
|
||||
|
||||
sb.append("Spawn spawn " + spawnLocation.x + " " + spawnLocation.y + " " + spawnLocation.z + "\n");
|
||||
}
|
||||
|
||||
synchronized(mgr.lock) {
|
||||
for(TileUpdate tu : mgr.tileUpdates) {
|
||||
if(tu.at >= cutoff) {
|
||||
sb.append(tu.tile.px + "_" + tu.tile.py + " " + tu.tile.zpx + "_" + tu.tile.zpy + " t\n");
|
||||
}
|
||||
}
|
||||
|
||||
for(TileUpdate tu : mgr.caveTileUpdates) {
|
||||
if(tu.at >= cutoff) {
|
||||
sb.append(tu.tile.px + "_" + tu.tile.py + " " + tu.tile.zpx + "_" + tu.tile.zpy + " c\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.write(sb.toString().getBytes());
|
||||
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
}
|
||||
catch (Exception anye) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>bin</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/core</directory>
|
||||
<outputDirectory>/dynmap</outputDirectory></fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}</directory>
|
||||
<outputDirectory>/dynmap</outputDirectory>
|
||||
<includes>
|
||||
<include>LICENSE</include></includes></fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/${artifactId}-${version}.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<destName>dynmap.jar</destName>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class Armor {
|
||||
/**
|
||||
* http://www.minecraftwiki.net/wiki/Item_Durability#Armor_durability
|
||||
* We rely on getArmorContents() to return 4 armor pieces in the order
|
||||
* of: boots, pants, chest, helmet
|
||||
*/
|
||||
private static final int armorPoints[] = {3, 6, 8, 3};
|
||||
|
||||
public static final int getArmorPoints(Player player) {
|
||||
int currentDurability = 0;
|
||||
int baseDurability = 0;
|
||||
int baseArmorPoints = 0;
|
||||
ItemStack[] itm = new ItemStack[4];
|
||||
PlayerInventory inv = player.getInventory();
|
||||
itm[0] = inv.getBoots();
|
||||
itm[1]= inv.getLeggings();
|
||||
itm[2] = inv.getChestplate();
|
||||
itm[3] = inv.getHelmet();
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(itm[i] == null) continue;
|
||||
int dur = itm[i].getDurability();
|
||||
int max = itm[i].getType().getMaxDurability();
|
||||
if(max <= 0) continue;
|
||||
if(i == 2)
|
||||
max = max + 1; /* Always 1 too low for chestplate */
|
||||
else
|
||||
max = max - 3; /* Always 3 too high, versus how client calculates it */
|
||||
baseDurability += max;
|
||||
currentDurability += max - dur;
|
||||
baseArmorPoints += armorPoints[i];
|
||||
}
|
||||
int ap = 0;
|
||||
if(baseDurability > 0)
|
||||
ap = ((baseArmorPoints - 1) * currentDurability) / baseDurability + 1;
|
||||
return ap;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Log;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public abstract class BukkitVersionHelper {
|
||||
|
||||
private static BukkitVersionHelper helper = null;
|
||||
|
||||
public static final BukkitVersionHelper getHelper() {
|
||||
if(helper == null) {
|
||||
if(Bukkit.getServer().getVersion().contains("MCPC")) {
|
||||
Log.severe("*********************************************************************************");
|
||||
Log.severe("* MCPC-Plus is no longer supported via the Bukkit version of Dynmap. *");
|
||||
Log.severe("* Install the appropriate Forge version of Dynmap. *");
|
||||
Log.severe("* Add the DynmapCBBridge plugin to enable support for Dynmap-compatible plugins *");
|
||||
Log.severe("*********************************************************************************");
|
||||
}
|
||||
else if(Bukkit.getServer().getVersion().contains("BukkitForge")) {
|
||||
Log.severe("*********************************************************************************");
|
||||
Log.severe("* BukkitForge is not supported via the Bukkit version of Dynmap. *");
|
||||
Log.severe("* Install the appropriate Forge version of Dynmap. *");
|
||||
Log.severe("* Add the DynmapCBBridge plugin to enable support for Dynmap-compatible plugins *");
|
||||
Log.severe("*********************************************************************************");
|
||||
}
|
||||
else {
|
||||
helper = new BukkitVersionHelperCB();
|
||||
}
|
||||
}
|
||||
return helper;
|
||||
}
|
||||
protected BukkitVersionHelper() {
|
||||
|
||||
}
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
public abstract Object[] getBiomeBaseList();
|
||||
/**
|
||||
* Get temperature from biomebase
|
||||
*/
|
||||
public abstract float getBiomeBaseTemperature(Object bb);
|
||||
/**
|
||||
* Get humidity from biomebase
|
||||
*/
|
||||
public abstract float getBiomeBaseHumidity(Object bb);
|
||||
/**
|
||||
* Get ID string from biomebase
|
||||
*/
|
||||
public abstract String getBiomeBaseIDString(Object bb);
|
||||
/**
|
||||
* Get ID from biomebase
|
||||
*/
|
||||
public abstract int getBiomeBaseID(Object bb);
|
||||
/**
|
||||
* Get net.minecraft.server.world for given world
|
||||
*/
|
||||
public abstract Object getNMSWorld(World w);
|
||||
/**
|
||||
* Get unload queue for given NMS world
|
||||
*/
|
||||
public abstract Object getUnloadQueue(Object nmsworld);
|
||||
/**
|
||||
* For testing unload queue for presence of givne chunk
|
||||
*/
|
||||
public abstract boolean isInUnloadQueue(Object unloadqueue, int x, int z);
|
||||
/**
|
||||
* Read raw biome ID from snapshot
|
||||
*/
|
||||
public abstract Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css);
|
||||
/**
|
||||
* Test if normal chunk snapshot
|
||||
*/
|
||||
public abstract boolean isCraftChunkSnapshot(ChunkSnapshot css);
|
||||
/**
|
||||
* Remove entities from given chunk
|
||||
*/
|
||||
public abstract void removeEntitiesFromChunk(Chunk c);
|
||||
/**
|
||||
* Get inhabited ticks count from chunk
|
||||
*/
|
||||
public abstract long getInhabitedTicks(Chunk c);
|
||||
/**
|
||||
* Get tile entities map from chunk
|
||||
*/
|
||||
public abstract Map getTileEntitiesForChunk(Chunk c);
|
||||
/**
|
||||
* Get X coordinate of tile entity
|
||||
*/
|
||||
public abstract int getTileEntityX(Object te);
|
||||
/**
|
||||
* Get Y coordinate of tile entity
|
||||
*/
|
||||
public abstract int getTileEntityY(Object te);
|
||||
/**
|
||||
* Get Z coordinate of tile entity
|
||||
*/
|
||||
public abstract int getTileEntityZ(Object te);
|
||||
/**
|
||||
* Read tile entity NBT
|
||||
*/
|
||||
public abstract Object readTileEntityNBT(Object te);
|
||||
/**
|
||||
* Get field value from NBT compound
|
||||
*/
|
||||
public abstract Object getFieldValue(Object nbt, String field);
|
||||
/**
|
||||
* Unload chunk no save needed
|
||||
*/
|
||||
public abstract void unloadChunkNoSave(World w, Chunk c, int cx, int cz);
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
public abstract String[] getBlockShortNames();
|
||||
/**
|
||||
* Get biome name list
|
||||
*/
|
||||
public abstract String[] getBiomeNames();
|
||||
/**
|
||||
* Get block material index list
|
||||
*/
|
||||
public abstract int[] getBlockMaterialMap();
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
private Class<?> nmsblock;
|
||||
private Class<?> nmsblockarray;
|
||||
private Class<?> nmsmaterial;
|
||||
private Field blockbyid;
|
||||
private Field blockname;
|
||||
private Field material;
|
||||
private Method blockbyidfunc; // 1.7+ method for getting block by id
|
||||
|
||||
BukkitVersionHelperCB() {
|
||||
}
|
||||
@Override
|
||||
protected String getNMSPackage() {
|
||||
Server srv = Bukkit.getServer();
|
||||
/* Get getHandle() method */
|
||||
try {
|
||||
Method m = srv.getClass().getMethod("getHandle");
|
||||
Object scm = m.invoke(srv); /* And use it to get SCM (nms object) */
|
||||
return scm.getClass().getPackage().getName();
|
||||
} catch (Exception x) {
|
||||
Log.severe("Error finding net.minecraft.server packages");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void loadNMS() {
|
||||
// Get block fields
|
||||
nmsblock = getNMSClass("net.minecraft.server.Block");
|
||||
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
|
||||
nmsmaterial = getNMSClass("net.minecraft.server.Material");
|
||||
blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||
if (blockbyid == null) {
|
||||
blockbyidfunc = getMethod(nmsblock, new String[] { "e" }, new Class[] { int.class });
|
||||
}
|
||||
blockname = getPrivateField(nmsblock, new String[] { "name", "b" }, String.class);
|
||||
material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||
|
||||
/* Set up biomebase fields */
|
||||
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
||||
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
||||
biomebaselist = getPrivateField(biomebase, new String[] { "biomes" }, biomebasearray);
|
||||
biomebasetemp = getField(biomebase, new String[] { "temperature", "F" }, float.class);
|
||||
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y", "af" }, String.class);
|
||||
biomebaseid = getField(biomebase, new String[] { "id" }, int.class);
|
||||
/* n.m.s.World */
|
||||
nmsworld = getNMSClass("net.minecraft.server.WorldServer");
|
||||
chunkprovserver = getNMSClass("net.minecraft.server.ChunkProviderServer");
|
||||
nmsw_chunkproviderserver = getField(nmsworld, new String[] { "chunkProviderServer" }, chunkprovserver);
|
||||
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
lhs_containskey = getMethod(longhashset, new String[] { "contains" }, new Class[] { int.class, int.class });
|
||||
}
|
||||
else {
|
||||
longhashset = getOBCClass("org.bukkit.craftbukkit.util.LongHashset");
|
||||
lhs_containskey = getMethod(longhashset, new String[] { "containsKey" }, new Class[] { int.class, int.class });
|
||||
}
|
||||
|
||||
cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, longhashset);
|
||||
if(cps_unloadqueue == null) {
|
||||
Log.info("Unload queue not found - default to unload all chunks");
|
||||
}
|
||||
/** n.m.s.Chunk */
|
||||
nmschunk = getNMSClass("net.minecraft.server.Chunk");
|
||||
nmsc_removeentities = getMethod(nmschunk, new String[] { "removeEntities" }, new Class[0]);
|
||||
nmsc_tileentities = getField(nmschunk, new String[] { "tileEntities" }, Map.class);
|
||||
nmsc_inhabitedticks = getFieldNoFail(nmschunk, new String[] { "s", "q" }, long.class);
|
||||
if (nmsc_inhabitedticks == null) {
|
||||
Log.info("inhabitedTicks field not found - inhabited shader not functional");
|
||||
}
|
||||
/** nbt classes */
|
||||
nbttagcompound = getNMSClass("net.minecraft.server.NBTTagCompound");
|
||||
nbttagbyte = getNMSClass("net.minecraft.server.NBTTagByte");
|
||||
nbttagshort = getNMSClass("net.minecraft.server.NBTTagShort");
|
||||
nbttagint = getNMSClass("net.minecraft.server.NBTTagInt");
|
||||
nbttaglong = getNMSClass("net.minecraft.server.NBTTagLong");
|
||||
nbttagfloat = getNMSClass("net.minecraft.server.NBTTagFloat");
|
||||
nbttagdouble = getNMSClass("net.minecraft.server.NBTTagDouble");
|
||||
nbttagbytearray = getNMSClass("net.minecraft.server.NBTTagByteArray");
|
||||
nbttagstring = getNMSClass("net.minecraft.server.NBTTagString");
|
||||
nbttagintarray = getNMSClass("net.minecraft.server.NBTTagIntArray");
|
||||
compound_get = getMethod(nbttagcompound, new String[] { "get" }, new Class[] { String.class });
|
||||
nbttagbyte_val = getPrivateField(nbttagbyte, new String[] { "data" }, byte.class);
|
||||
nbttagshort_val = getPrivateField(nbttagshort, new String[] { "data" }, short.class);
|
||||
nbttagint_val = getPrivateField(nbttagint, new String[] { "data" }, int.class);
|
||||
nbttaglong_val = getPrivateField(nbttaglong, new String[] { "data" }, long.class);
|
||||
nbttagfloat_val = getPrivateField(nbttagfloat, new String[] { "data" }, float.class);
|
||||
nbttagdouble_val = getPrivateField(nbttagdouble, new String[] { "data" }, double.class);
|
||||
nbttagbytearray_val = getPrivateField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
||||
nbttagstring_val = getPrivateField(nbttagstring, new String[] { "data" }, String.class);
|
||||
nbttagintarray_val = getPrivateField(nbttagintarray, new String[] { "data" }, int[].class);
|
||||
|
||||
/** Tile entity */
|
||||
nms_tileentity = getNMSClass("net.minecraft.server.TileEntity");
|
||||
nmst_readnbt = getMethod(nms_tileentity, new String[] { "b" }, new Class[] { nbttagcompound });
|
||||
nmst_x = getField(nms_tileentity, new String[] { "x" }, int.class);
|
||||
nmst_y = getField(nms_tileentity, new String[] { "y" }, int.class);
|
||||
nmst_z = getField(nms_tileentity, new String[] { "z" }, int.class);
|
||||
}
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||
this.removeEntitiesFromChunk(c);
|
||||
w.unloadChunk(cx, cz, false, false);
|
||||
}
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
@Override
|
||||
public String[] getBlockShortNames() {
|
||||
try {
|
||||
String[] names = new String[4096];
|
||||
if (blockbyid != null) {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
names[i] = (String)blockname.get(byid[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||
if (blk != null) {
|
||||
names[i] = (String)blockname.get(blk);
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
/**
|
||||
* Get biome name list
|
||||
*/
|
||||
@Override
|
||||
public String[] getBiomeNames() {
|
||||
String[] names;
|
||||
/* Find array of biomes in biomebase */
|
||||
Object[] biomelist = getBiomeBaseList();
|
||||
names = new String[biomelist.length];
|
||||
/* Loop through list, starting afer well known biomes */
|
||||
for(int i = 0; i < biomelist.length; i++) {
|
||||
Object bb = biomelist[i];
|
||||
if(bb != null) {
|
||||
names[i] = getBiomeBaseIDString(bb);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
/**
|
||||
* Get block material index list
|
||||
*/
|
||||
public int[] getBlockMaterialMap() {
|
||||
try {
|
||||
int[] map = new int[4096];
|
||||
if (blockbyid != null) {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
Object mat = (Object)material.get(byid[i]);
|
||||
if (mat != null) {
|
||||
map[i] = mats.indexOf(mat);
|
||||
if (map[i] < 0) {
|
||||
map[i] = mats.size();
|
||||
mats.add(mat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||
if (blk != null) {
|
||||
Object mat = (Object)material.get(blk);
|
||||
if (mat != null) {
|
||||
map[i] = mats.indexOf(mat);
|
||||
if (map[i] < 0) {
|
||||
map[i] = mats.size();
|
||||
mats.add(mat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
@@ -1,388 +0,0 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Log;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
private String obc_package; // Package used for org.bukkit.craftbukkit
|
||||
protected String nms_package; // Package used for net.minecraft.server
|
||||
private boolean failed;
|
||||
private static final Object[] nullargs = new Object[0];
|
||||
private static final Map nullmap = Collections.emptyMap();
|
||||
|
||||
/** CraftChunkSnapshot */
|
||||
private Class<?> craftchunksnapshot;
|
||||
private Field ccss_biome;
|
||||
/** CraftChunk */
|
||||
private Class<?> craftchunk;
|
||||
private Method cc_gethandle;
|
||||
/** CraftWorld */
|
||||
private Class<?> craftworld;
|
||||
private Method cw_gethandle;
|
||||
|
||||
/** BiomeBase related helpers */
|
||||
protected Class<?> biomebase;
|
||||
protected Class<?> biomebasearray;
|
||||
protected Field biomebaselist;
|
||||
protected Field biomebasetemp;
|
||||
protected Field biomebasehumi;
|
||||
protected Field biomebaseidstring;
|
||||
protected Field biomebaseid;
|
||||
/** n.m.s.World */
|
||||
protected Class<?> nmsworld;
|
||||
protected Class<?> chunkprovserver;
|
||||
protected Class<?> longhashset;
|
||||
protected Field nmsw_chunkproviderserver;
|
||||
protected Field cps_unloadqueue;
|
||||
protected Method lhs_containskey;
|
||||
/** n.m.s.Chunk */
|
||||
protected Class<?> nmschunk;
|
||||
protected Method nmsc_removeentities;
|
||||
protected Field nmsc_tileentities;
|
||||
protected Field nmsc_inhabitedticks;
|
||||
/** nbt classes */
|
||||
protected Class<?> nbttagcompound;
|
||||
protected Class<?> nbttagbyte;
|
||||
protected Class<?> nbttagshort;
|
||||
protected Class<?> nbttagint;
|
||||
protected Class<?> nbttaglong;
|
||||
protected Class<?> nbttagfloat;
|
||||
protected Class<?> nbttagdouble;
|
||||
protected Class<?> nbttagbytearray;
|
||||
protected Class<?> nbttagstring;
|
||||
protected Class<?> nbttagintarray;
|
||||
protected Method compound_get;
|
||||
protected Field nbttagbyte_val;
|
||||
protected Field nbttagshort_val;
|
||||
protected Field nbttagint_val;
|
||||
protected Field nbttaglong_val;
|
||||
protected Field nbttagfloat_val;
|
||||
protected Field nbttagdouble_val;
|
||||
protected Field nbttagbytearray_val;
|
||||
protected Field nbttagstring_val;
|
||||
protected Field nbttagintarray_val;
|
||||
/** Tile entity */
|
||||
protected Class<?> nms_tileentity;
|
||||
protected Method nmst_readnbt;
|
||||
protected Field nmst_x;
|
||||
protected Field nmst_y;
|
||||
protected Field nmst_z;
|
||||
|
||||
BukkitVersionHelperGeneric() {
|
||||
failed = false;
|
||||
Server srv = Bukkit.getServer();
|
||||
/* Look up base classname for bukkit server - tells us OBC package */
|
||||
obc_package = Bukkit.getServer().getClass().getPackage().getName();
|
||||
/* Get NMS package */
|
||||
nms_package = getNMSPackage();
|
||||
if(nms_package == null) {
|
||||
failed = true;
|
||||
}
|
||||
/* Craftworld fields */
|
||||
craftworld = getOBCClass("org.bukkit.craftbukkit.CraftWorld");
|
||||
cw_gethandle = getMethod(craftworld, new String[] { "getHandle" }, new Class[0]);
|
||||
/* CraftChunkSnapshot */
|
||||
craftchunksnapshot = getOBCClass("org.bukkit.craftbukkit.CraftChunkSnapshot");
|
||||
ccss_biome = getPrivateField(craftchunksnapshot, new String[] { "biome" }, biomebasearray);
|
||||
/* CraftChunk */
|
||||
craftchunk = getOBCClass("org.bukkit.craftbukkit.CraftChunk");
|
||||
cc_gethandle = getMethod(craftchunk, new String[] { "getHandle" }, new Class[0]);
|
||||
/* Get NMS classes and fields */
|
||||
if(!failed)
|
||||
loadNMS();
|
||||
|
||||
if(failed)
|
||||
throw new IllegalArgumentException("Error initializing dynmap - bukkit version incompatible!");
|
||||
}
|
||||
|
||||
protected abstract void loadNMS();
|
||||
|
||||
protected abstract String getNMSPackage();
|
||||
|
||||
protected Class<?> getOBCClass(String classname) {
|
||||
return getClassByName(classname, "org.bukkit.craftbukkit", obc_package, false);
|
||||
}
|
||||
|
||||
protected Class<?> getOBCClassNoFail(String classname) {
|
||||
return getClassByName(classname, "org.bukkit.craftbukkit", obc_package, true);
|
||||
}
|
||||
|
||||
protected Class<?> getNMSClass(String classname) {
|
||||
return getClassByName(classname, "net.minecraft.server", nms_package, false);
|
||||
}
|
||||
|
||||
protected Class<?> getClassByName(String classname, String base, String mapping, boolean nofail) {
|
||||
String n = classname;
|
||||
int idx = classname.indexOf(base);
|
||||
if(idx >= 0) {
|
||||
n = classname.substring(0, idx) + mapping + classname.substring(idx + base.length());
|
||||
}
|
||||
try {
|
||||
return Class.forName(n);
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
try {
|
||||
return Class.forName(classname);
|
||||
} catch (ClassNotFoundException cnfx2) {
|
||||
if(!nofail) {
|
||||
Log.severe("Cannot find " + classname);
|
||||
failed = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get field
|
||||
*/
|
||||
protected Field getField(Class<?> cls, String[] ids, Class<?> type) {
|
||||
return getField(cls, ids, type, false);
|
||||
}
|
||||
protected Field getFieldNoFail(Class<?> cls, String[] ids, Class<?> type) {
|
||||
return getField(cls, ids, type, true);
|
||||
}
|
||||
/**
|
||||
* Get field
|
||||
*/
|
||||
private Field getField(Class<?> cls, String[] ids, Class<?> type, boolean nofail) {
|
||||
if((cls == null) || (type == null)) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
Field f = cls.getField(id);
|
||||
if(f.getType().isAssignableFrom(type)) {
|
||||
return f;
|
||||
}
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
}
|
||||
}
|
||||
if(!nofail) {
|
||||
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get private field
|
||||
*/
|
||||
protected Field getPrivateField(Class<?> cls, String[] ids, Class<?> type) {
|
||||
if((cls == null) || (type == null)) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
Field f = cls.getDeclaredField(id);
|
||||
if(f.getType().isAssignableFrom(type)) {
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
}
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
}
|
||||
}
|
||||
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
return null;
|
||||
}
|
||||
protected Object getFieldValue(Object obj, Field field, Object def) {
|
||||
if((obj != null) && (field != null)) {
|
||||
try {
|
||||
return field.get(obj);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
return def;
|
||||
}
|
||||
/**
|
||||
* Get method
|
||||
*/
|
||||
protected Method getMethod(Class<?> cls, String[] ids, Class[] args) {
|
||||
if(cls == null) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
return cls.getMethod(id, args);
|
||||
} catch (SecurityException e) {
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
Log.severe("Unable to find method " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
return null;
|
||||
}
|
||||
private Object callMethod(Object obj, Method meth, Object[] args, Object def) {
|
||||
if((obj == null) || (meth == null)) {
|
||||
return def;
|
||||
}
|
||||
try {
|
||||
return meth.invoke(obj, args);
|
||||
} catch (IllegalArgumentException iax) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
public Object[] getBiomeBaseList() {
|
||||
return (Object[]) getFieldValue(biomebase, biomebaselist, new Object[0]);
|
||||
}
|
||||
/** Get temperature from biomebase */
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
return (Float) getFieldValue(bb, biomebasetemp, 0.5F);
|
||||
}
|
||||
/** Get humidity from biomebase */
|
||||
public float getBiomeBaseHumidity(Object bb) {
|
||||
return (Float) getFieldValue(bb, biomebasehumi, 0.5F);
|
||||
}
|
||||
/** Get ID string from biomebase */
|
||||
public String getBiomeBaseIDString(Object bb) {
|
||||
return (String) getFieldValue(bb, biomebaseidstring, null);
|
||||
}
|
||||
/** Get ID from biomebase */
|
||||
public int getBiomeBaseID(Object bb) {
|
||||
return (Integer) getFieldValue(bb, biomebaseid, -1);
|
||||
}
|
||||
|
||||
/* Get net.minecraft.server.world for given world */
|
||||
public Object getNMSWorld(World w) {
|
||||
return callMethod(w, cw_gethandle, nullargs, null);
|
||||
}
|
||||
|
||||
/* Get unload queue for given NMS world */
|
||||
public Object getUnloadQueue(Object nmsworld) {
|
||||
Object cps = getFieldValue(nmsworld, nmsw_chunkproviderserver, null); // Get chunkproviderserver
|
||||
if(cps != null) {
|
||||
return getFieldValue(cps, cps_unloadqueue, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* For testing unload queue for presence of givne chunk */
|
||||
public boolean isInUnloadQueue(Object unloadqueue, int x, int z) {
|
||||
if(unloadqueue != null) {
|
||||
return (Boolean)callMethod(unloadqueue, lhs_containskey, new Object[] { x, z }, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css) {
|
||||
return (Object[])getFieldValue(css, ccss_biome, null);
|
||||
}
|
||||
public boolean isCraftChunkSnapshot(ChunkSnapshot css) {
|
||||
if(craftchunksnapshot != null) {
|
||||
return craftchunksnapshot.isAssignableFrom(css.getClass());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/** Remove entities from given chunk */
|
||||
public void removeEntitiesFromChunk(Chunk c) {
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
if(omsc != null) {
|
||||
callMethod(omsc, nmsc_removeentities, nullargs, null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get inhabited ticks count from chunk
|
||||
*/
|
||||
private static final Long zero = new Long(0);
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
if (nmsc_inhabitedticks == null) {
|
||||
return 0;
|
||||
}
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
if(omsc != null) {
|
||||
return (Long)getFieldValue(omsc, nmsc_inhabitedticks, zero);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get tile entities map from chunk */
|
||||
public Map getTileEntitiesForChunk(Chunk c) {
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
if(omsc != null) {
|
||||
return (Map)getFieldValue(omsc, nmsc_tileentities, nullmap);
|
||||
}
|
||||
return nullmap;
|
||||
}
|
||||
/**
|
||||
* Get X coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityX(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_x, 0);
|
||||
}
|
||||
/**
|
||||
* Get Y coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityY(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_y, 0);
|
||||
}
|
||||
/**
|
||||
* Get Z coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityZ(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_z, 0);
|
||||
}
|
||||
/**
|
||||
* Read tile entity NBT
|
||||
*/
|
||||
public Object readTileEntityNBT(Object te) {
|
||||
if(nbttagcompound == null) return null;
|
||||
Object nbt = null;
|
||||
try {
|
||||
nbt = nbttagcompound.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
if(nbt != null) {
|
||||
callMethod(te, nmst_readnbt, new Object[] { nbt }, null);
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
/**
|
||||
* Get field value from NBT compound
|
||||
*/
|
||||
public Object getFieldValue(Object nbt, String field) {
|
||||
Object val = callMethod(nbt, compound_get, new Object[] { field }, null);
|
||||
if(val == null) return null;
|
||||
Class<?> valcls = val.getClass();
|
||||
if(valcls.equals(nbttagbyte)) {
|
||||
return getFieldValue(val, nbttagbyte_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagshort)) {
|
||||
return getFieldValue(val, nbttagshort_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagint)) {
|
||||
return getFieldValue(val, nbttagint_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttaglong)) {
|
||||
return getFieldValue(val, nbttaglong_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagfloat)) {
|
||||
return getFieldValue(val, nbttagfloat_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagdouble)) {
|
||||
return getFieldValue(val, nbttagdouble_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagbytearray)) {
|
||||
return getFieldValue(val, nbttagbytearray_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagstring)) {
|
||||
return getFieldValue(val, nbttagstring_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagintarray)) {
|
||||
return getFieldValue(val, nbttagintarray_val, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user