mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e73e88281c | |||
| fde3d14abd | |||
| 6cf60b3d53 | |||
| 9e29cb8e44 | |||
| fca05e399a | |||
| a6490743ca | |||
| 7da1051d5f | |||
| ddf14b7c3b | |||
| 38a4d869f6 | |||
| 905802e558 | |||
| 30db9c04b6 | |||
| 2401eff676 | |||
| b5700bd462 | |||
| 5d9677b350 | |||
| cf77737f85 | |||
| 8a03a29f0a | |||
| 8031110a59 | |||
| cf0c60d877 | |||
| 0a4761f525 | |||
| ab46d250b1 | |||
| df8013489d | |||
| 133d3078d7 | |||
| 2a056033b8 | |||
| a5428b56f1 | |||
| ff79c2f4fc | |||
| 18462b5caf | |||
| ebfa3eaec1 | |||
| 96673f0fb3 | |||
| fc451fd002 | |||
| 2f1b1789fd | |||
| 01b054e972 | |||
| 5d35205cae | |||
| 58c7d6378c | |||
| d95213e7dd | |||
| 4f5063155e | |||
| 2d4e233005 | |||
| afc0d9bd6b | |||
| 267b423ff1 | |||
| d523ce8a41 | |||
| ee7e6eedc8 | |||
| 4d6d156e9c | |||
| 177310a949 | |||
| 0707953718 | |||
| 8546b2205e | |||
| d154f23bab | |||
| 0b38a4cec8 | |||
| 02aedc9478 | |||
| 3702e07210 | |||
| 6afb0d9b92 | |||
| 1d6cedeeb0 | |||
| a3528e9937 | |||
| bae2a48a83 | |||
| 11b2123f14 | |||
| f93f37deea | |||
| cf5e2e00e6 | |||
| 121c1050ce |
@@ -0,0 +1,201 @@
|
||||
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.
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<version>0.36</version>
|
||||
<version>0.70.2</version>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -133,7 +133,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>[1.1-R5-SNAPSHOT,1.7)</version>
|
||||
<version>[1.2.5-R4.0,1.7)</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
@@ -179,5 +179,10 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/PermissionsBukkit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.2.5-R5.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
<includes>
|
||||
<include>version.js</include></includes>
|
||||
<filtered>true</filtered></fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}</directory>
|
||||
<outputDirectory>/dynmap</outputDirectory>
|
||||
<includes>
|
||||
<include>LICENSE</include></includes></fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
@@ -13,16 +15,20 @@ import org.dynmap.utils.MapChunkCache;
|
||||
|
||||
public class BukkitWorld extends DynmapWorld {
|
||||
private World world;
|
||||
private World.Environment env;
|
||||
private boolean skylight;
|
||||
|
||||
public BukkitWorld(World w) {
|
||||
super(w.getName(), w.getMaxHeight(), w.getSeaLevel());
|
||||
|
||||
world = w;
|
||||
env = world.getEnvironment();
|
||||
skylight = (env == World.Environment.NORMAL);
|
||||
new Permission("dynmap.world." + getName(), "Dynmap access for world " + getName(), PermissionDefault.OP);
|
||||
}
|
||||
/* Test if world is nether */
|
||||
@Override
|
||||
public boolean isNether() {
|
||||
return world.getEnvironment() == World.Environment.NETHER;
|
||||
return env == World.Environment.NETHER;
|
||||
}
|
||||
/* Get world spawn location */
|
||||
@Override
|
||||
@@ -66,7 +72,7 @@ public class BukkitWorld extends DynmapWorld {
|
||||
/* Test if sky light level is requestable */
|
||||
@Override
|
||||
public boolean canGetSkyLightLevel() {
|
||||
return true;
|
||||
return skylight;
|
||||
}
|
||||
/* Return sky light level */
|
||||
@Override
|
||||
@@ -78,7 +84,7 @@ public class BukkitWorld extends DynmapWorld {
|
||||
*/
|
||||
@Override
|
||||
public String getEnvironment() {
|
||||
return world.getEnvironment().name().toLowerCase();
|
||||
return env.name().toLowerCase();
|
||||
}
|
||||
/**
|
||||
* Get map chunk cache for world
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,5 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -10,7 +8,9 @@ import java.util.ListIterator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.CraftChunk;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.LongHashset;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
@@ -19,7 +19,7 @@ import org.dynmap.Log;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.dynmap.utils.MapIterator.BlockStep;
|
||||
import org.dynmap.utils.BlockStep;
|
||||
import org.getspout.spoutapi.block.SpoutChunk;
|
||||
|
||||
/**
|
||||
@@ -27,16 +27,10 @@ import org.getspout.spoutapi.block.SpoutChunk;
|
||||
*/
|
||||
public class NewMapChunkCache implements MapChunkCache {
|
||||
private static boolean init = false;
|
||||
private static Method poppreservedchunk = null;
|
||||
private static Method gethandle = null;
|
||||
private static Method removeentities = null;
|
||||
private static Method getworldhandle = null;
|
||||
private static boolean use_spout = false;
|
||||
private static boolean use_sections = false;
|
||||
|
||||
private World w;
|
||||
private DynmapWorld dw;
|
||||
private Object craftworld;
|
||||
private int nsect;
|
||||
private List<DynmapChunk> chunks;
|
||||
private ListIterator<DynmapChunk> iterator;
|
||||
@@ -69,6 +63,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
* Iterator for traversing map chunk cache (base is for non-snapshot)
|
||||
*/
|
||||
public class OurMapIterator implements MapIterator {
|
||||
@SuppressWarnings("unused")
|
||||
private int x, y, z, chunkindex, bx, bz, off;
|
||||
private ChunkSnapshot snap;
|
||||
private BlockStep laststep;
|
||||
@@ -101,16 +96,21 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
exceptions++;
|
||||
}
|
||||
laststep = BlockStep.Y_MINUS;
|
||||
typeid = blkdata = -1;
|
||||
if((y >= 0) && (y < worldheight))
|
||||
typeid = blkdata = -1;
|
||||
else
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
public final int getBlockTypeID() {
|
||||
if(typeid < 0)
|
||||
if(typeid < 0) {
|
||||
typeid = snap.getBlockTypeId(bx, y, bz);
|
||||
}
|
||||
return typeid;
|
||||
}
|
||||
public final int getBlockData() {
|
||||
if(blkdata < 0)
|
||||
if(blkdata < 0) {
|
||||
blkdata = snap.getBlockData(bx, y, bz);
|
||||
}
|
||||
return blkdata;
|
||||
}
|
||||
public int getBlockSkyLight() {
|
||||
@@ -353,6 +353,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
* Step current position in given direction
|
||||
*/
|
||||
public final void stepPosition(BlockStep step) {
|
||||
typeid = -1;
|
||||
blkdata = -1;
|
||||
switch(step.ordinal()) {
|
||||
case 0:
|
||||
x++;
|
||||
@@ -372,6 +374,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
if(y >= worldheight) {
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
z++;
|
||||
@@ -407,6 +412,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
break;
|
||||
case 4:
|
||||
y--;
|
||||
if(y < 0) {
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
z--;
|
||||
@@ -426,8 +434,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
break;
|
||||
}
|
||||
laststep = step;
|
||||
typeid = -1;
|
||||
blkdata = -1;
|
||||
}
|
||||
/**
|
||||
* Unstep current position to previous position
|
||||
@@ -449,8 +455,12 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
else
|
||||
laststep = BlockStep.Y_MINUS;
|
||||
this.y = y;
|
||||
typeid = -1;
|
||||
blkdata = -1;
|
||||
if((y < 0) || (y >= worldheight)) {
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
else {
|
||||
typeid = blkdata = -1;
|
||||
}
|
||||
}
|
||||
public final int getX() {
|
||||
return x;
|
||||
@@ -493,9 +503,12 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
@Override
|
||||
public final boolean isEmptySection() {
|
||||
if(isSectionNotEmpty[chunkindex] == null)
|
||||
try {
|
||||
return !isSectionNotEmpty[chunkindex][y >> 4];
|
||||
} catch (Exception x) {
|
||||
initSectionData(chunkindex);
|
||||
return !isSectionNotEmpty[chunkindex][y >> 4];
|
||||
return !isSectionNotEmpty[chunkindex][y >> 4];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,18 +596,26 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
public boolean isSectionEmpty(int sy) {
|
||||
return (sy < 4);
|
||||
}
|
||||
public int getTopNonEmptySection() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SpoutChunkSnapshot implements ChunkSnapshot {
|
||||
private ChunkSnapshot chunk;
|
||||
private short[] customids; /* (X << 11) | (Z << 7) | Y */
|
||||
private short[] customids;
|
||||
private final int shiftx;
|
||||
private final int shiftz;
|
||||
|
||||
SpoutChunkSnapshot(ChunkSnapshot chunk, short[] customids) {
|
||||
SpoutChunkSnapshot(ChunkSnapshot chunk, short[] customids, int height) {
|
||||
this.chunk = chunk;
|
||||
this.customids = customids.clone();
|
||||
int sx = 11;
|
||||
int sz = 7; /* 128 high values */
|
||||
while(height > 128) {
|
||||
sx++;
|
||||
sz++;
|
||||
height = (height >> 1);
|
||||
}
|
||||
shiftx = sx;
|
||||
shiftz = sz;
|
||||
}
|
||||
/* Need these for interface, but not used */
|
||||
public final int getX() { return chunk.getX(); }
|
||||
@@ -606,7 +627,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
public final long getCaptureFullTime() { return chunk.getCaptureFullTime(); }
|
||||
|
||||
public final int getBlockTypeId(int x, int y, int z) {
|
||||
int id = customids[(x << 11) | (z << 7) | y];
|
||||
int id = customids[(x << shiftx) | (z << shiftz) | y];
|
||||
if(id != 0) return id;
|
||||
return chunk.getBlockTypeId(x, y, z);
|
||||
}
|
||||
@@ -634,39 +655,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
/**
|
||||
* Construct empty cache
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public NewMapChunkCache() {
|
||||
if(!init) {
|
||||
/* Get CraftWorld.popPreservedChunk(x,z) - reduces memory bloat from map traversals (optional) */
|
||||
try {
|
||||
Class c = Class.forName("org.bukkit.craftbukkit.CraftWorld");
|
||||
poppreservedchunk = c.getDeclaredMethod("popPreservedChunk", new Class[] { int.class, int.class });
|
||||
/* getHandle() */
|
||||
getworldhandle = c.getDeclaredMethod("getHandle", new Class[0]);
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
}
|
||||
/* Get CraftChunk.getChunkSnapshot(boolean,boolean,boolean) and CraftChunk.getHandle() */
|
||||
try {
|
||||
Class c = Class.forName("org.bukkit.craftbukkit.CraftChunk");
|
||||
gethandle = c.getDeclaredMethod("getHandle", new Class[0]);
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
}
|
||||
/* Get Chunk.removeEntities() */
|
||||
try {
|
||||
Class c = Class.forName("net.minecraft.server.Chunk");
|
||||
removeentities = c.getDeclaredMethod("removeEntities", new Class[0]);
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
}
|
||||
/* Check for ChunkSnapshot.isSectionEmpty(int) method */
|
||||
try {
|
||||
ChunkSnapshot.class.getDeclaredMethod("isSectionEmpty", new Class[] { int.class });
|
||||
use_sections = true;
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
}
|
||||
|
||||
use_spout = DynmapPlugin.plugin.hasSpout();
|
||||
|
||||
init = true;
|
||||
@@ -676,12 +666,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
this.dw = dw;
|
||||
this.w = dw.getWorld();
|
||||
nsect = dw.worldheight >> 4;
|
||||
if((getworldhandle != null) && (craftworld == null)) {
|
||||
try {
|
||||
craftworld = getworldhandle.invoke(w); /* World.getHandle() */
|
||||
} catch (Exception x) {
|
||||
}
|
||||
}
|
||||
this.chunks = chunks;
|
||||
/* Compute range */
|
||||
if(chunks.size() == 0) {
|
||||
@@ -716,7 +700,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
SpoutChunk sc = (SpoutChunk)c;
|
||||
short[] custids = sc.getCustomBlockIds();
|
||||
if(custids != null) {
|
||||
return new SpoutChunkSnapshot(ss, custids);
|
||||
return new SpoutChunkSnapshot(ss, custids, c.getWorld().getMaxHeight());
|
||||
}
|
||||
}
|
||||
return ss;
|
||||
@@ -724,6 +708,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
|
||||
public int loadChunks(int max_to_load) {
|
||||
long t0 = System.nanoTime();
|
||||
CraftWorld cw = (CraftWorld)w;
|
||||
LongHashset unloadqueue = cw.getHandle().chunkProviderServer.unloadQueue;
|
||||
int cnt = 0;
|
||||
if(iterator == null)
|
||||
iterator = chunks.listIterator();
|
||||
@@ -767,13 +753,41 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
chunks_attempted++;
|
||||
boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
|
||||
boolean didload = w.loadChunk(chunk.x, chunk.z, false);
|
||||
boolean didload = false;
|
||||
boolean isunloadpending = unloadqueue.containsKey(chunk.x, chunk.z);
|
||||
if (isunloadpending) { /* Workaround: can't be pending if not loaded */
|
||||
wasLoaded = true;
|
||||
}
|
||||
try {
|
||||
if (!wasLoaded) {
|
||||
didload = w.loadChunk(chunk.x, chunk.z, false);
|
||||
}
|
||||
else { /* If already was loaded, no need to load */
|
||||
didload = true;
|
||||
}
|
||||
} catch (Throwable t) { /* Catch chunk error from Bukkit */
|
||||
Log.warning("Bukkit error loading chunk " + chunk.x + "," + chunk.z + " on " + w.getName());
|
||||
if(!wasLoaded) { /* If wasn't loaded, we loaded it if it now is */
|
||||
didload = w.isChunkLoaded(chunk.x, chunk.z);
|
||||
}
|
||||
}
|
||||
boolean didgenerate = false;
|
||||
/* If we didn't load, and we're supposed to generate, do it */
|
||||
if((!didload) && do_generate && vis)
|
||||
didgenerate = didload = w.loadChunk(chunk.x, chunk.z, true);
|
||||
/* If it did load, make cache of it */
|
||||
if(didload) {
|
||||
Chunk c = w.getChunkAt(chunk.x, chunk.z); /* Get the chunk */
|
||||
/* Test if chunk isn't populated */
|
||||
boolean populated = true;
|
||||
//TODO: figure out why this doesn't appear to be reliable in Bukkit
|
||||
//if((nmschunk != null) && (doneflag != null)) {
|
||||
// try {
|
||||
// populated = doneflag.getBoolean(nmschunk);
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// } catch (IllegalAccessException e) {
|
||||
// }
|
||||
//}
|
||||
if(!vis) {
|
||||
if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
|
||||
ss = STONE;
|
||||
@@ -782,8 +796,10 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
else
|
||||
ss = EMPTY;
|
||||
}
|
||||
else if(!populated) { /* If not populated, treat as empty */
|
||||
ss = EMPTY;
|
||||
}
|
||||
else {
|
||||
Chunk c = w.getChunkAt(chunk.x, chunk.z);
|
||||
if(blockdata || highesty) {
|
||||
ss = c.getChunkSnapshot(highesty, biome, biomeraw);
|
||||
if(use_spout) {
|
||||
@@ -797,46 +813,25 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
}
|
||||
snaparray[(chunk.x-x_min) + (chunk.z - z_min)*x_dim] = ss;
|
||||
}
|
||||
if ((!wasLoaded) && didload) {
|
||||
chunks_read++;
|
||||
/* It looks like bukkit "leaks" entities - they don't get removed from the world-level table
|
||||
* when chunks are unloaded but not saved - removing them seems to do the trick */
|
||||
if(!(didgenerate && do_save)) {
|
||||
boolean did_remove = false;
|
||||
Chunk cc = w.getChunkAt(chunk.x, chunk.z);
|
||||
if((gethandle != null) && (removeentities != null)) {
|
||||
try {
|
||||
Object chk = gethandle.invoke(cc);
|
||||
if(chk != null) {
|
||||
removeentities.invoke(chk);
|
||||
did_remove = true;
|
||||
}
|
||||
} catch (InvocationTargetException itx) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
if(!did_remove) {
|
||||
if(cc != null) {
|
||||
for(Entity e: cc.getEntities())
|
||||
e.remove();
|
||||
}
|
||||
/* If wasn't loaded before, we need to do unload */
|
||||
if (!wasLoaded) {
|
||||
chunks_read++;
|
||||
/* It looks like bukkit "leaks" entities - they don't get removed from the world-level table
|
||||
* when chunks are unloaded but not saved - removing them seems to do the trick */
|
||||
if(!(didgenerate && do_save)) {
|
||||
CraftChunk cc = (CraftChunk)c;
|
||||
cc.getHandle().removeEntities();
|
||||
}
|
||||
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
||||
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
||||
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
||||
* while the actual in-use chunk area for a player where the chunks are managed
|
||||
* by the MC base server is 21x21 (or about a 160 block radius).
|
||||
* Also, if we did generate it, need to save it */
|
||||
w.unloadChunk(chunk.x, chunk.z, didgenerate && do_save, false);
|
||||
}
|
||||
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
||||
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
||||
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
||||
* while the actual in-use chunk area for a player where the chunks are managed
|
||||
* by the MC base server is 21x21 (or about a 160 block radius).
|
||||
* Also, if we did generate it, need to save it */
|
||||
w.unloadChunk(chunk.x, chunk.z, didgenerate && do_save, false);
|
||||
/* And pop preserved chunk - this is a bad leak in Bukkit for map traversals like us */
|
||||
try {
|
||||
if(poppreservedchunk != null)
|
||||
poppreservedchunk.invoke(w, chunk.x, chunk.z);
|
||||
} catch (Exception x) {
|
||||
Log.severe("Cannot pop preserved chunk - " + x.toString());
|
||||
else if (isunloadpending) { /* Else, if loaded and unload is pending */
|
||||
w.unloadChunkRequest(chunk.x, chunk.z); /* Request new unload */
|
||||
}
|
||||
}
|
||||
cnt++;
|
||||
@@ -923,16 +918,10 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
private void initSectionData(int idx) {
|
||||
isSectionNotEmpty[idx] = new boolean[nsect + 1];
|
||||
int maxy = 0;
|
||||
if(snaparray[idx] != EMPTY) {
|
||||
if(!use_sections) {
|
||||
Arrays.fill(isSectionNotEmpty[idx], true);
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < nsect; i++) {
|
||||
if(snaparray[idx].isSectionEmpty(i) == false) {
|
||||
isSectionNotEmpty[idx][i] = true;
|
||||
}
|
||||
for(int i = 0; i < nsect; i++) {
|
||||
if(snaparray[idx].isSectionEmpty(i) == false) {
|
||||
isSectionNotEmpty[idx][i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1048,7 +1037,10 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
static {
|
||||
Biome[] b = Biome.values();
|
||||
BiomeMap[] bm = BiomeMap.values();
|
||||
biome_to_bmap = new BiomeMap[b.length];
|
||||
biome_to_bmap = new BiomeMap[256];
|
||||
for(int i = 0; i < biome_to_bmap.length; i++) {
|
||||
biome_to_bmap[i] = BiomeMap.NULL;
|
||||
}
|
||||
for(int i = 0; i < b.length; i++) {
|
||||
String bs = b[i].toString();
|
||||
for(int j = 0; j < bm.length; j++) {
|
||||
|
||||
@@ -9,11 +9,13 @@ import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
import org.getspout.spoutapi.block.design.BlockDesign;
|
||||
import org.getspout.spoutapi.block.design.GenericBlockDesign;
|
||||
@@ -53,13 +55,42 @@ public class SpoutPluginBlocks {
|
||||
sb.append("block:id=" + blk.getCustomId() + ",allfaces=12049,transparency=TRANSPARENT\n");
|
||||
}
|
||||
|
||||
private static String fixIDString(String id) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = id.length();
|
||||
sb.setLength(len);
|
||||
for(int i = 0; i < len; i++) {
|
||||
char c = id.charAt(i);
|
||||
if(Character.isJavaIdentifierStart(c)) {
|
||||
sb.setCharAt(i, c);
|
||||
}
|
||||
else {
|
||||
sb.setCharAt(i, '_');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/* Process spout blocks - return true if something changed */
|
||||
public boolean processSpoutBlocks(File datadir) {
|
||||
public boolean processSpoutBlocks(DynmapPlugin plugin, DynmapCore core) {
|
||||
/* First, see if any spout plugins that need to be enabled */
|
||||
for(Plugin p : plugin.getServer().getPluginManager().getPlugins()) {
|
||||
List<String> dep = p.getDescription().getDepend();
|
||||
if((dep != null) && (dep.contains("Spout"))) {
|
||||
Log.info("Found Spout plugin: " + p.getName());
|
||||
if(p.isEnabled() == false) {
|
||||
plugin.getPluginLoader().enablePlugin(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File datadir = core.getDataFolder();
|
||||
if(textYPosField == null) {
|
||||
if(initSpoutAccess() == false)
|
||||
return false;
|
||||
}
|
||||
HashMap<String, String> texturelist = new HashMap<String, String>();
|
||||
boolean use_existing_texture = core.configuration.getBoolean("spout/use-existing-textures", true);
|
||||
|
||||
int cnt = 0;
|
||||
File f = new File(datadir, "texturepacks/standard/spout");
|
||||
@@ -72,7 +103,7 @@ public class SpoutPluginBlocks {
|
||||
/* Loop through blocks - try to freshen files, if needed */
|
||||
for(CustomBlock b : cb) {
|
||||
BlockDesign bd = b.getBlockDesign();
|
||||
String blkid = bd.getTexturePlugin() + "." + b.getName();
|
||||
String blkid = bd.getTexturePlugin() + "." + fixIDString(b.getName());
|
||||
/* If not GenericCubiodBlockDesign, we don't handle it */
|
||||
if((bd instanceof GenericCuboidBlockDesign) == false) {
|
||||
Log.info("Block " + blkid + " not suppored - only cubiod blocks");
|
||||
@@ -109,53 +140,59 @@ public class SpoutPluginBlocks {
|
||||
String txtid = texturelist.get(txname); /* Get texture */
|
||||
if(txtid == null) { /* Not found yet */
|
||||
File imgfile = new File(f, blkid + ".png");
|
||||
BufferedImage img = null;
|
||||
boolean urlloaded = false;
|
||||
try {
|
||||
URL url = new URL(txname);
|
||||
img = ImageIO.read(url); /* Load skin for player */
|
||||
urlloaded = true;
|
||||
} catch (IOException iox) {
|
||||
if(txname.startsWith("http") == false) { /* Not URL - try file */
|
||||
File tf = new File(txname);
|
||||
if(tf.exists() == false) {
|
||||
/* Horrible hack - try to find temp file (some SpoutMaterials versions) */
|
||||
try {
|
||||
File tmpf = File.createTempFile("dynmap", "test");
|
||||
|
||||
tf = new File(tmpf.getParent(), txname);
|
||||
tmpf.delete();
|
||||
} catch (IOException iox2) {}
|
||||
|
||||
/* If not reusing loaded textures OR not previously loaded */
|
||||
if((!use_existing_texture) || (!imgfile.exists())) {
|
||||
BufferedImage img = null;
|
||||
boolean urlloaded = false;
|
||||
try {
|
||||
URL url = new URL(txname);
|
||||
img = ImageIO.read(url); /* Load skin for player */
|
||||
urlloaded = true;
|
||||
} catch (IOException iox) {
|
||||
if(txname.startsWith("http") == false) { /* Not URL - try file */
|
||||
File tf = new File(txname);
|
||||
if(tf.exists() == false) {
|
||||
/* Horrible hack - try to find temp file (some SpoutMaterials versions) */
|
||||
try {
|
||||
File tmpf = File.createTempFile("dynmap", "test");
|
||||
|
||||
tf = new File(tmpf.getParent(), txname);
|
||||
tmpf.delete();
|
||||
} catch (IOException iox2) {}
|
||||
}
|
||||
if(tf.exists()) {
|
||||
try {
|
||||
img = ImageIO.read(tf);
|
||||
urlloaded = true;
|
||||
} catch (IOException iox3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tf.exists()) {
|
||||
try {
|
||||
img = ImageIO.read(tf);
|
||||
urlloaded = true;
|
||||
} catch (IOException iox3) {
|
||||
if(img == null) {
|
||||
Log.severe("Error loading texture for custom block '" + blkid + "' (" + b.getCustomId() + ") from " + txname + "(" + iox.getMessage() + ")");
|
||||
if(imgfile.exists()) {
|
||||
try {
|
||||
img = ImageIO.read(imgfile); /* Load existing */
|
||||
Log.info("Loaded cached texture file for " + blkid);
|
||||
} catch (IOException iox2) {
|
||||
Log.severe("Error loading cached texture file for " + blkid + " - " + iox2.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(img == null) {
|
||||
Log.severe("Error loading texture for custom block '" + blkid + "' (" + b.getCustomId() + ") from " + txname + "(" + iox.getMessage() + ")");
|
||||
if(imgfile.exists()) {
|
||||
try {
|
||||
img = ImageIO.read(imgfile); /* Load existing */
|
||||
Log.info("Loaded cached texture file for " + blkid);
|
||||
} catch (IOException iox2) {
|
||||
Log.severe("Error loading cached texture file for " + blkid + " - " + iox2.getMessage());
|
||||
}
|
||||
if(img != null) {
|
||||
try {
|
||||
if(urlloaded)
|
||||
ImageIO.write(img, "png", imgfile);
|
||||
} catch (IOException iox) {
|
||||
Log.severe("Error writing " + blkid + ".png");
|
||||
} finally {
|
||||
img.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(img != null) {
|
||||
try {
|
||||
if(urlloaded)
|
||||
ImageIO.write(img, "png", imgfile);
|
||||
} catch (IOException iox) {
|
||||
Log.severe("Error writing " + blkid + ".png");
|
||||
} finally {
|
||||
img.flush();
|
||||
}
|
||||
if(imgfile.exists()) { /* If exists now, log it */
|
||||
String tfid = "txtid" + texturelist.size();
|
||||
sb.append("texturefile:id=" + tfid + ",filename=spout/" + blkid + ".png,xcount=" + w/sz + ",ycount=" + h/sz + "\n");
|
||||
texturelist.put(txname, tfid);
|
||||
@@ -166,7 +203,7 @@ public class SpoutPluginBlocks {
|
||||
blks.add(b);
|
||||
|
||||
sb.append("block:id=" + b.getCustomId() + ",data=*,bottom=" + txtidx[0] + ",west=" +txtidx[1] + ",south=" + txtidx[2] + ",east=" + txtidx[3] + ",north="+txtidx[4]+",top="+txtidx[5]);
|
||||
if(b.isOpaque() == false)
|
||||
if(b.getBlockId() == Material.GLASS.getId())
|
||||
sb.append(",transparency=TRANSPARENT");
|
||||
sb.append(",txtid=" + txfileid + "\n");
|
||||
cnt++;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dynmap.bukkit.permissions;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -10,20 +11,23 @@ import org.bukkit.entity.Player;
|
||||
import org.dynmap.Log;
|
||||
|
||||
public class BukkitPermissions implements PermissionProvider {
|
||||
String name;
|
||||
protected String name;
|
||||
protected Map<String, Boolean> pd;
|
||||
|
||||
public static BukkitPermissions create(String name) {
|
||||
public static BukkitPermissions create(String name, Map<String,Boolean> pd) {
|
||||
try {
|
||||
Class.forName("org.bukkit.permissions.PermissibleBase"); /* See if class exists */
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
return null;
|
||||
}
|
||||
Log.info("Using Bukkit Permissions (superperms) for access control");
|
||||
return new BukkitPermissions(name);
|
||||
Log.info("Web interface permissions only available for online users");
|
||||
return new BukkitPermissions(name, pd);
|
||||
}
|
||||
|
||||
public BukkitPermissions(String name) {
|
||||
public BukkitPermissions(String name, Map<String, Boolean> pd) {
|
||||
this.name = name;
|
||||
this.pd = pd;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,10 +54,16 @@ public class BukkitPermissions implements PermissionProvider {
|
||||
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
Player p = Bukkit.getPlayerExact(name);
|
||||
if (p != null)
|
||||
Player p = Bukkit.getPlayerExact(player);
|
||||
if (p != null) {
|
||||
return p.hasPermission(name + "." + perm);
|
||||
else
|
||||
}
|
||||
else {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
if((op != null) && op.isOp()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ public class NijikokunPermissions implements PermissionProvider {
|
||||
return null;
|
||||
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
|
||||
Log.info("Using Permissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new NijikokunPermissions(permissionsPlugin, name);
|
||||
}
|
||||
@@ -47,6 +50,8 @@ public class NijikokunPermissions implements PermissionProvider {
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
if(permissions == null)
|
||||
permissions = ((Permissions)plugin).getHandler();
|
||||
HashSet<String> hasperms = new HashSet<String>();
|
||||
for (String pp : perms) {
|
||||
if (permissions.has(defworld, player, name + "." + pp)) {
|
||||
@@ -58,6 +63,8 @@ public class NijikokunPermissions implements PermissionProvider {
|
||||
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
if(permissions == null)
|
||||
permissions = ((Permissions)plugin).getHandler();
|
||||
return permissions.has(defworld, player, name + "." + perm);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ public class PEXPermissions implements PermissionProvider {
|
||||
if (permissionsPlugin == null)
|
||||
return null;
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
if(PermissionsEx.isAvailable() == false)
|
||||
return null;
|
||||
Log.info("Using PermissionsEx " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
|
||||
@@ -1,65 +1,34 @@
|
||||
package org.dynmap.bukkit.permissions;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.Log;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||
|
||||
import de.bananaco.bpermissions.api.ApiLayer;
|
||||
import de.bananaco.bpermissions.api.util.CalculableType;
|
||||
import de.bananaco.bpermissions.api.util.Permission;
|
||||
|
||||
public class PermBukkitPermissions implements PermissionProvider {
|
||||
String name;
|
||||
public class PermBukkitPermissions extends BukkitPermissions {
|
||||
PermissionsPlugin plugin;
|
||||
Map<String, Boolean> pd;
|
||||
|
||||
public static PermBukkitPermissions create(Server server, String name) {
|
||||
public static PermBukkitPermissions create(Server server, String name, Map<String, Boolean> pd) {
|
||||
Plugin permissionsPlugin = server.getPluginManager().getPlugin("PermissionsBukkit");
|
||||
if (permissionsPlugin == null)
|
||||
return null;
|
||||
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
|
||||
Log.info("Using PermissionsBukkit " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new PermBukkitPermissions(permissionsPlugin, name);
|
||||
Log.info("Web interface permissions only available for online users");
|
||||
return new PermBukkitPermissions(permissionsPlugin, name, pd);
|
||||
}
|
||||
|
||||
public PermBukkitPermissions(Plugin permissionsPlugin, String name) {
|
||||
this.name = name;
|
||||
public PermBukkitPermissions(Plugin permissionsPlugin, String name, Map<String, Boolean> pd) {
|
||||
super(name, pd);
|
||||
plugin = (PermissionsPlugin) permissionsPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
return (player != null) ? plugin.getPlayerInfo(player.getName()).getPermissions().containsKey(name + "." + permission) : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
Map<String, Boolean> prm = plugin.getPlayerInfo(player).getPermissions();
|
||||
HashSet<String> hasperms = new HashSet<String>();
|
||||
for (String pp : perms) {
|
||||
Boolean pb = prm.get(name + "." + pp);
|
||||
if ((pb != null) && pb.booleanValue()) {
|
||||
hasperms.add(pp);
|
||||
}
|
||||
}
|
||||
return hasperms;
|
||||
}
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
Boolean b = plugin.getPlayerInfo(player).getPermissions().get(name + "." + perm);
|
||||
if (b != null)
|
||||
return b;
|
||||
else
|
||||
return false;
|
||||
this.pd = pd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,55 @@
|
||||
package org.dynmap.bukkit.permissions;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.Log;
|
||||
|
||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||
import de.bananaco.bpermissions.api.User;
|
||||
import de.bananaco.bpermissions.api.WorldManager;
|
||||
|
||||
import de.bananaco.bpermissions.api.ApiLayer;
|
||||
import de.bananaco.bpermissions.api.util.CalculableType;
|
||||
import de.bananaco.bpermissions.api.util.Permission;
|
||||
public class bPermPermissions extends BukkitPermissions {
|
||||
WorldManager wm;
|
||||
|
||||
public class bPermPermissions implements PermissionProvider {
|
||||
String name;
|
||||
String defworld;
|
||||
|
||||
public static bPermPermissions create(Server server, String name) {
|
||||
public static bPermPermissions create(Server server, String name, Map<String,Boolean> pd) {
|
||||
Plugin permissionsPlugin = server.getPluginManager().getPlugin("bPermissions");
|
||||
if (permissionsPlugin == null)
|
||||
return null;
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
|
||||
Log.info("Using bPermissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new bPermPermissions(name);
|
||||
return new bPermPermissions(name, pd);
|
||||
}
|
||||
|
||||
public bPermPermissions(String name) {
|
||||
this.name = name;
|
||||
defworld = Bukkit.getServer().getWorlds().get(0).getName();
|
||||
public bPermPermissions(String name, Map<String,Boolean> pd) {
|
||||
super(name, pd);
|
||||
wm = WorldManager.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
return (player != null) ? ApiLayer.hasPermission(defworld, CalculableType.USER, player.getName(), name + "." + permission) : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
HashSet<String> hasperms = new HashSet<String>();
|
||||
for (String pp : perms) {
|
||||
if(ApiLayer.hasPermission(defworld, CalculableType.USER, player, name + "." + pp)) {
|
||||
hasperms.add(pp);
|
||||
User usr = wm.getDefaultWorld().getUser(player);
|
||||
if(usr != null) {
|
||||
try { usr.calculateEffectivePermissions(); } catch (Exception x) {}
|
||||
Map<String,Boolean> p = usr.getMappedPermissions();
|
||||
for (String pp : perms) {
|
||||
String permval = name + "." + pp;
|
||||
Boolean v = p.get(permval);
|
||||
if (v != null) {
|
||||
if(v.booleanValue())
|
||||
hasperms.add(permval);
|
||||
}
|
||||
else {
|
||||
v = pd.get(permval);
|
||||
if((v != null) && v.booleanValue())
|
||||
hasperms.add(permval);
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasperms;
|
||||
@@ -53,7 +57,26 @@ public class bPermPermissions implements PermissionProvider {
|
||||
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
return ApiLayer.hasPermission(defworld, CalculableType.USER, player, name + "." + perm);
|
||||
boolean rslt;
|
||||
String permval = name + "." + perm;
|
||||
User usr = wm.getDefaultWorld().getUser(player);
|
||||
if(usr != null) {
|
||||
try { usr.calculateEffectivePermissions(); } catch (Exception x) {}
|
||||
if(usr.getMappedPermissions().containsKey(permval)) {
|
||||
rslt = usr.hasPermission(permval);
|
||||
}
|
||||
else {
|
||||
Boolean v = pd.get(permval);
|
||||
if(v != null)
|
||||
rslt = v;
|
||||
else
|
||||
rslt = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
rslt = false;
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,13 +30,18 @@ components:
|
||||
block-banned-player-chat: true
|
||||
# Require login for web-to-server chat (requires login-enabled: true)
|
||||
webchat-requires-login: false
|
||||
|
||||
# If set to true, users must have dynmap.webchat permission in order to chat
|
||||
webchat-permissions: false
|
||||
# Limit length of single chat messages
|
||||
chatlengthlimit: 256
|
||||
# # Optional - make players hidden when they are inside/underground/in shadows (#=light level: 0=full shadow,15=sky)
|
||||
# hideifshadow: 4
|
||||
# # Optional - make player hidden when they are under cover (#=sky light level,0=underground,15=open to sky)
|
||||
# hideifundercover: 14
|
||||
# # (Optional) if true, players that are crouching/sneaking will be hidden
|
||||
# hideifsneaking: false
|
||||
hideifsneaking: false
|
||||
# If true, player positions/status is protected (login with ID with dynmap.playermarkers.seeall permission required for info other than self)
|
||||
protected-player-info: false
|
||||
#- class: org.dynmap.JsonFileClientUpdateComponent
|
||||
# writeinterval: 1
|
||||
# sendhealth: true
|
||||
@@ -53,6 +58,10 @@ components:
|
||||
# hideifsneaking: false
|
||||
# # Require login for web-to-server chat (requires login-enabled: true)
|
||||
# webchat-requires-login: false
|
||||
# # If set to true, users must have dynmap.webchat permission in order to chat
|
||||
# webchat-permissions: false
|
||||
# # Limit length of single chat messages
|
||||
# chatlengthlimit: 256
|
||||
|
||||
- class: org.dynmap.SimpleWebChatComponent
|
||||
allowchat: true
|
||||
@@ -130,11 +139,14 @@ components:
|
||||
hidey: false
|
||||
show-mcr: false
|
||||
|
||||
# Note: more than one logo component can be defined
|
||||
#- class: org.dynmap.ClientComponent
|
||||
# type: logo
|
||||
# text: "Dynmap"
|
||||
# #logourl: "images/block_surface.png"
|
||||
# linkurl: "http://forums.bukkit.org/threads/dynmap.489/"
|
||||
# # Valid positions: top-left, top-right, bottom-left, bottom-right
|
||||
# position: bottom-right
|
||||
|
||||
#- class: org.dynmap.ClientComponent
|
||||
# type: inactive
|
||||
@@ -198,34 +210,44 @@ correct-water-lighting: true
|
||||
# Control updating of player faces, once loaded (if faces are being managed by other apps or manually)
|
||||
#refreshskins: false
|
||||
|
||||
# Customize URL used for fetching player skins (%player% is macro for name)
|
||||
skin-url: "http://s3.amazonaws.com/MinecraftSkins/%player%.png"
|
||||
|
||||
# Control behavior for new (1.0+) compass orientation (sunrise moved 90 degrees: east is now what used to be south)
|
||||
# default is 'newrose' (preserve pre-1.0 maps, rotate rose)
|
||||
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
|
||||
compass-mode: newnorth
|
||||
|
||||
# Enable Industrial Craft 2 block rendering support (core, Advanced Machines, Charging Bench, Power Converters)
|
||||
### Mod block support ###
|
||||
# Enable Industrial Craft 2 block rendering support (core, Advanced Machines, Charging Bench, Power Converters, Compact Solars, Nuclear Control)
|
||||
#ic2-support: true
|
||||
#ic2-advancesmachines-support: true
|
||||
#ic2-chargingbench-support: true
|
||||
#ic2-powerconverters-support: true
|
||||
|
||||
#ic2-compactsolars-support: true
|
||||
#ic2-nuclearcontrol-support: true
|
||||
# Enable BuildCraft block rendering support
|
||||
#buildcraft-support: true
|
||||
|
||||
# Enable RedPower2 block rendering support
|
||||
#redpower2-support: true
|
||||
|
||||
# Enable NetherOres block rendering support
|
||||
#netherores-support: true
|
||||
|
||||
# Enable RailCraft block rendering support
|
||||
#railcraft-support: true
|
||||
|
||||
# Enable Kaevator's Superslopes block rendering support
|
||||
#superslopes-support: true
|
||||
|
||||
# Enabled ComputerCraft block rendering support
|
||||
#computercraft-support: true
|
||||
# Enabled LC Trees++ block rendering support
|
||||
#lctrees-support: true
|
||||
# Enable Forestry block rending support
|
||||
#forestry-support: true
|
||||
# Enable IronCheck block rendering support
|
||||
#ironchest-support: true
|
||||
# Enable TubeCraft block rendering support
|
||||
#tubecraft-support: true
|
||||
# Enable Ender Storage block rendering support
|
||||
#enderstorage-support: true
|
||||
|
||||
render-triggers:
|
||||
#- playermove
|
||||
@@ -240,10 +262,11 @@ render-triggers:
|
||||
- blockspread
|
||||
- pistonmoved
|
||||
- explosion
|
||||
- blockfromto
|
||||
- blockphysics
|
||||
#- blockfromto
|
||||
#- blockphysics
|
||||
- structuregrow
|
||||
- blockgrow
|
||||
#- blockredstone
|
||||
|
||||
# Title for the web page - if not specified, defaults to the server's name (unless it is the default of 'Unknown Server')
|
||||
#webpage-title: "My Awesome Server Map"
|
||||
@@ -327,9 +350,6 @@ defaultmap: flat
|
||||
#followzoom: 3
|
||||
#followmap: surface
|
||||
|
||||
# Option to enable workaround for incorrectly encoded unicode in Cyrillic MC/Bukkit (not good for other code pages)
|
||||
cyrillic-support: false
|
||||
|
||||
# If true, make persistent record of IP addresses used by player logins, to support web IP to player matching
|
||||
persist-ids-by-ip: true
|
||||
|
||||
@@ -340,6 +360,32 @@ msg:
|
||||
chatrequireslogin: "Chat Requires Login"
|
||||
chatnotallowed: "You are not permitted to send chat messages"
|
||||
|
||||
# URL for client configuration (only need to be tailored for proxies or other non-standard configurations)
|
||||
url:
|
||||
# configuration URL
|
||||
#configuration: "up/configuration"
|
||||
# update URL
|
||||
#update: "up/world/{world}/{timestamp}"
|
||||
# sendmessage URL
|
||||
#sendmessage: "up/sendmessage"
|
||||
# login URL
|
||||
#login: "up/login"
|
||||
# register URL
|
||||
#register: "up/register"
|
||||
# tiles base URL
|
||||
#tiles: "tiles/"
|
||||
# markers base URL
|
||||
#markers: "tiles/"
|
||||
|
||||
# Spout support controls
|
||||
spout:
|
||||
# If false, ignore spout even if detected
|
||||
enabled: true
|
||||
# If true, previously loaded textures will be assumed to still be valid (faster startup, but
|
||||
# can result in stale textures if originals are updated - delete files in texturepacks/standard/spoout
|
||||
# to clean cached textures and force reload on next startup)
|
||||
use-existing-textures: true
|
||||
|
||||
# Set to true to enable verbose startup messages - can help with debugging map configuration problems
|
||||
# Set to false for a much quieter startup log
|
||||
verbose: false
|
||||
|
||||
@@ -2,7 +2,7 @@ name: dynmap
|
||||
main: org.dynmap.bukkit.DynmapPlugin
|
||||
version: "${project.version}-${BUILD_NUMBER}"
|
||||
authors: [FrozenCow, mikeprimm]
|
||||
softdepend: [ Permissions, PermissionEx, bPermissions, PermissionsBukkit, SpoutMaterials ]
|
||||
softdepend: [ Permissions, PermissionEx, bPermissions, PermissionsBukkit ]
|
||||
commands:
|
||||
dynmap:
|
||||
description: Controls Dynmap.
|
||||
@@ -155,6 +155,7 @@ permissions:
|
||||
dynmap.dmap.perspectivelist: true
|
||||
dynmap.dmap.shaderlist: true
|
||||
dynmap.dmap.lightinglist: true
|
||||
dynmap.playermarkers.seeall: true
|
||||
dynmap.render:
|
||||
description: Allows /dynmap render command
|
||||
default: true
|
||||
@@ -320,3 +321,6 @@ permissions:
|
||||
dynmap.webchat:
|
||||
description: Allows web chat (if login required for webchat)
|
||||
default: true
|
||||
dynmap.playermarkers.seeall:
|
||||
description: Allow all players to be seen by user on web UI
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user