mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-29 12:37:53 +01:00
Fix errors
This commit is contained in:
parent
e71fd64e9c
commit
a924dcd66a
@ -20,7 +20,7 @@ subprojects {
|
||||
apply plugin: 'idea'
|
||||
|
||||
dependencies {
|
||||
compile(group: 'com.sk89q', name: 'worldedit', version:'6.0.0-SNAPSHOT') {
|
||||
compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.1-SNAPSHOT') {
|
||||
exclude(module: 'bukkit-classloader-check')
|
||||
}
|
||||
compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
|
||||
|
0
build/classes/production/forge_main/config.yml
Normal file
0
build/classes/production/forge_main/config.yml
Normal file
@ -6,7 +6,6 @@ dependencies {
|
||||
compile 'javax.websocket:javax.websocket-api:1.1'
|
||||
compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT'
|
||||
compile 'org.bukkit:bukkit:1.9-R0.1-SNAPSHOT'
|
||||
compile 'org.PrimeSoft:blockshub:1.2'
|
||||
compile 'com.massivecraft:factions:2.8.0'
|
||||
compile 'com.drtshock:factions:1.6.9.5'
|
||||
compile 'me.ryanhamshire:GriefPrevention:11.5.2'
|
||||
|
2
bukkit/build/tmp/shadowJar/MANIFEST.MF
Normal file
2
bukkit/build/tmp/shadowJar/MANIFEST.MF
Normal file
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BukkitMask extends FaweMask {
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2) {
|
||||
super(new BlockVector(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()));
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location loc = player.getLocation();
|
||||
final PS ps = PS.valueOf(loc);
|
||||
@ -35,7 +35,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
final Chunk chunk = loc.getChunk();
|
||||
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ();
|
||||
|
@ -24,7 +24,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Chunk chunk = player.getLocation().getChunk();
|
||||
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness");
|
||||
@ -73,7 +73,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
|
||||
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ();
|
||||
|
@ -1,97 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
|
||||
public class FaweMask {
|
||||
private String description = null;
|
||||
private Location position1;
|
||||
private Location position2;
|
||||
|
||||
public FaweMask(final Location pos1, final Location pos2, final String id) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("Locations cannot be null!");
|
||||
}
|
||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||
}
|
||||
this.description = id;
|
||||
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public FaweMask(final Location pos1, final Location pos2) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("Locations cannot be null!");
|
||||
}
|
||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||
}
|
||||
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public HashSet<RegionWrapper> getRegions() {
|
||||
final Location lower = this.getLowerBound();
|
||||
final Location upper = this.getUpperBound();
|
||||
return new HashSet<>(Arrays.asList(new RegionWrapper(lower.getBlockX(), upper.getBlockX(), lower.getBlockZ(), upper.getBlockZ())));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Location getLowerBound() {
|
||||
return this.position1;
|
||||
}
|
||||
|
||||
public Location getUpperBound() {
|
||||
return this.position2;
|
||||
}
|
||||
|
||||
public void setBounds(final Location pos1, final Location pos2) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("Locations cannot be null!");
|
||||
}
|
||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||
}
|
||||
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public Location[] getBounds() {
|
||||
final Location[] locations = { this.position1, this.position2 };
|
||||
return locations;
|
||||
}
|
||||
|
||||
public boolean contains(final Location loc) {
|
||||
if (this.position1.getWorld().equals(loc.getWorld())) {
|
||||
if (loc.getBlockX() < this.position1.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockX() > this.position2.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockZ() < this.position1.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockZ() > this.position2.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockY() < this.position1.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockY() > this.position2.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
|
||||
@ -32,7 +32,7 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
|
||||
claim.getGreaterBoundaryCorner().getBlockX();
|
||||
final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CLAIM:" + claim.toString();
|
||||
|
@ -25,7 +25,7 @@ public class PlotMeFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final Plot plot = this.plotme.getPlotMeCoreManager().getPlotById(new BukkitPlayer(player));
|
||||
@ -38,7 +38,7 @@ public class PlotMeFeature extends BukkitMaskManager implements Listener {
|
||||
.getGenManager(player.getWorld().getName()).bottomZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||
final Location pos2 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).topX(plot.getId(), new BukkitWorld(player.getWorld())), 256, this.plotme
|
||||
.getGenManager(player.getWorld().getName()).topZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return plot.getId();
|
||||
|
@ -28,7 +28,7 @@ public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final PlotPlayer pp = PlotPlayer.wrap(fp.parent);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
@ -66,7 +66,7 @@ public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
||||
for (final com.intellectualcrafters.plot.object.RegionWrapper current : regions) {
|
||||
faweRegions.add(new RegionWrapper(current.minX, current.maxX, current.minZ, current.maxZ));
|
||||
}
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PLOT^2:" + id;
|
||||
|
@ -26,7 +26,7 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.PLOT, location);
|
||||
@ -34,7 +34,7 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
|
||||
if (myfield.getOwner().equalsIgnoreCase(player.getName()) || (myfield.getAllowed().contains(player.getName()))) {
|
||||
final Location pos1 = new Location(location.getWorld(), myfield.getCorners().get(0).getBlockX(), myfield.getCorners().get(0).getBlockY(), myfield.getCorners().get(0).getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), myfield.getCorners().get(1).getBlockX(), myfield.getCorners().get(1).getBlockY(), myfield.getCorners().get(1).getBlockZ());
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FIELD:" + myfield.toString();
|
||||
|
@ -23,7 +23,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final ClaimedResidence residence = Residence.getResidenceManager().getByLoc(location);
|
||||
@ -32,7 +32,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
final CuboidArea area = residence.getAreaArray()[0];
|
||||
final Location pos1 = area.getHighLoc();
|
||||
final Location pos2 = area.getLowLoc();
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RESIDENCE: " + residence.getName();
|
||||
|
@ -25,7 +25,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
try {
|
||||
@ -57,7 +57,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
final Chunk chunk = location.getChunk();
|
||||
final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PLOT:" + location.getChunk().getX() + "," + location.getChunk().getZ();
|
||||
|
@ -72,14 +72,14 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final ProtectedRegion myregion = this.isowner(player, location);
|
||||
if (myregion != null) {
|
||||
final Location pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
||||
return new FaweMask(pos1, pos2) {
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return myregion.getId();
|
||||
|
@ -2,6 +2,7 @@ dependencies {
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'org.yaml:snakeyaml:1.16'
|
||||
compile 'com.google.code.gson:gson:2.2.4'
|
||||
compile 'org.PrimeSoft:blockshub:1.2'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
|
674
core/build/resources/main/LICENSE
Normal file
674
core/build/resources/main/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
2
core/build/tmp/jar/MANIFEST.MF
Normal file
2
core/build/tmp/jar/MANIFEST.MF
Normal file
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
@ -28,7 +28,7 @@ public class Stream extends FaweCommand {
|
||||
}
|
||||
final File file = Fawe.get().getWorldEdit().getWorkingDirectoryFile(Fawe.get().getWorldEdit().getConfiguration().saveDir + File.separator + args[0]);
|
||||
if (!file.exists()) {
|
||||
BBC.SCHEMATIC_NOT_FOUND.send(player, args);
|
||||
BBC.SCHEMATIC_NOT_FOUND.send(player, args[0]);
|
||||
return false;
|
||||
}
|
||||
FaweAPI.streamSchematicAsync(file, player.getLocation());
|
||||
|
83
core/src/main/java/com/boydti/fawe/regions/FaweMask.java
Normal file
83
core/src/main/java/com/boydti/fawe/regions/FaweMask.java
Normal file
@ -0,0 +1,83 @@
|
||||
package com.boydti.fawe.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
|
||||
public class FaweMask {
|
||||
private String description = null;
|
||||
private BlockVector position1;
|
||||
private BlockVector position2;
|
||||
|
||||
public FaweMask(final BlockVector pos1, final BlockVector pos2, final String id) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("BlockVectors cannot be null!");
|
||||
}
|
||||
this.description = id;
|
||||
this.position1 = new BlockVector(Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new BlockVector(Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public FaweMask(final BlockVector pos1, final BlockVector pos2) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("BlockVectors cannot be null!");
|
||||
}
|
||||
this.position1 = new BlockVector(Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new BlockVector(Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public HashSet<RegionWrapper> getRegions() {
|
||||
final BlockVector lower = this.getLowerBound();
|
||||
final BlockVector upper = this.getUpperBound();
|
||||
return new HashSet<>(Arrays.asList(new RegionWrapper(lower.getBlockX(), upper.getBlockX(), lower.getBlockZ(), upper.getBlockZ())));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public BlockVector getLowerBound() {
|
||||
return this.position1;
|
||||
}
|
||||
|
||||
public BlockVector getUpperBound() {
|
||||
return this.position2;
|
||||
}
|
||||
|
||||
public void setBounds(final BlockVector pos1, final BlockVector pos2) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("BlockVectors cannot be null!");
|
||||
}
|
||||
this.position1 = new BlockVector(Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new BlockVector(Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public BlockVector[] getBounds() {
|
||||
final BlockVector[] BlockVectors = { this.position1, this.position2 };
|
||||
return BlockVectors;
|
||||
}
|
||||
|
||||
public boolean contains(final BlockVector loc) {
|
||||
if (loc.getBlockX() < this.position1.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockX() > this.position2.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockZ() < this.position1.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockZ() > this.position2.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockY() < this.position1.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockY() > this.position2.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.regions.FaweMask;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
|
||||
public abstract class FaweMaskManager<T> {
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.boydti.fawe.bukkit.regions.FaweMask;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class WEManager {
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor {
|
||||
|
||||
private final FaweCommand cmd;
|
||||
|
||||
public BukkitCommand(final FaweCommand cmd) {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
final FawePlayer plr = Fawe.imp().wrap(sender);
|
||||
if (!sender.hasPermission(this.cmd.getPerm())) {
|
||||
BBC.NO_PERM.send(plr, this.cmd.getPerm());
|
||||
return true;
|
||||
}
|
||||
this.cmd.execute(plr, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
|
||||
public class BukkitPlayer extends FawePlayer<Player> {
|
||||
|
||||
public BukkitPlayer(final Player parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.parent.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return this.parent.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String perm) {
|
||||
return this.parent.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermission(final String perm, final boolean flag) {
|
||||
/*
|
||||
* Permissions are used to managing WorldEdit region restrictions
|
||||
* - The `/wea` command will give/remove the required bypass permission
|
||||
*/
|
||||
if (Fawe.<FaweBukkit> imp().getVault() == null) {
|
||||
this.parent.addAttachment(Fawe.<FaweBukkit> imp()).setPermission("fawe.bypass", flag);
|
||||
} else if (flag) {
|
||||
Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(this.parent, perm);
|
||||
} else {
|
||||
Fawe.<FaweBukkit> imp().getVault().permission.playerRemove(this.parent, perm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
this.parent.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(final String cmd) {
|
||||
Bukkit.getServer().dispatchCommand(this.parent, cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweLocation getLocation() {
|
||||
final Location loc = this.parent.getLocation();
|
||||
return new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.entity.Player getPlayer() {
|
||||
return Fawe.<FaweBukkit> imp().getWorldEditPlugin().wrapPlayer(this.parent);
|
||||
}
|
||||
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.lang.mutable.MutableInt;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
public class BukkitTaskMan extends TaskManager {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
public BukkitTaskMan(final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int repeat(final Runnable r, final int interval) {
|
||||
return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, r, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int repeatAsync(final Runnable r, final int interval) {
|
||||
return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, r, interval, interval);
|
||||
}
|
||||
|
||||
public MutableInt index = new MutableInt(0);
|
||||
public HashMap<Integer, Integer> tasks = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void async(final Runnable r) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, r).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(final Runnable r) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTask(this.plugin, r).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void later(final Runnable r, final int delay) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, r, delay).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void laterAsync(final Runnable r, final int delay) {
|
||||
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, r, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(final int task) {
|
||||
if (task != -1) {
|
||||
Bukkit.getScheduler().cancelTask(task);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,298 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.bukkit.regions.FactionsFeature;
|
||||
import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature;
|
||||
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
|
||||
import com.boydti.fawe.bukkit.regions.PlotMeFeature;
|
||||
import com.boydti.fawe.bukkit.regions.PlotSquaredFeature;
|
||||
import com.boydti.fawe.bukkit.regions.PreciousStonesFeature;
|
||||
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
|
||||
import com.boydti.fawe.bukkit.regions.TownyFeature;
|
||||
import com.boydti.fawe.bukkit.regions.Worldguard;
|
||||
import com.boydti.fawe.bukkit.v1_8.BukkitEditSessionWrapper_1_8;
|
||||
import com.boydti.fawe.bukkit.v1_8.BukkitQueue_1_8;
|
||||
import com.boydti.fawe.bukkit.v1_9.BukkitQueue_1_9;
|
||||
import com.boydti.fawe.object.EditSessionWrapper;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.FaweQueue;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
public class FaweBukkit extends JavaPlugin implements IFawe {
|
||||
|
||||
private VaultUtil vault;
|
||||
private WorldEditPlugin worldedit;
|
||||
|
||||
public VaultUtil getVault() {
|
||||
return this.vault;
|
||||
}
|
||||
|
||||
public WorldEditPlugin getWorldEditPlugin() {
|
||||
if (this.worldedit == null) {
|
||||
this.worldedit = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
}
|
||||
return this.worldedit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
Fawe.set(this);
|
||||
try {
|
||||
final Class<?> clazz = Class.forName("org.spigotmc.AsyncCatcher");
|
||||
final Field field = clazz.getDeclaredField("enabled");
|
||||
field.set(null, false);
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
this.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(final String s) {
|
||||
this.getLogger().info(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDirectory() {
|
||||
return this.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupCommand(final String label, final FaweCommand cmd) {
|
||||
this.getCommand(label).setExecutor(new BukkitCommand(cmd));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FawePlayer<Player> wrap(final Object obj) {
|
||||
if (obj.getClass() == String.class) {
|
||||
return new BukkitPlayer(Bukkit.getPlayer((String) obj));
|
||||
} else if (obj instanceof Player) {
|
||||
return new BukkitPlayer((Player) obj);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kinda a really messy class I just copied over from an old project<br>
|
||||
* - Still works, so cbf cleaning it up<br>
|
||||
* - Completely optional to have this class enabled since things get cancelled further down anyway<br>
|
||||
* - Useful since it informs the player why an edit changed no blocks etc.<br>
|
||||
* - Predicts the number of blocks changed and cancels the edit if it's too large<br>
|
||||
* - Predicts where the edit will effect and cancels it if it's outside a region<br>
|
||||
* - Restricts the brush iteration limit<br>
|
||||
*/
|
||||
@Override
|
||||
public void setupWEListener() {
|
||||
this.getServer().getPluginManager().registerEvents(new WEListener(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vault isn't required, but used for setting player permissions (WorldEdit bypass)
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void setupVault() {
|
||||
try {
|
||||
this.vault = new VaultUtil();
|
||||
} catch (final Throwable e) {
|
||||
this.debug("&cPlease install vault!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The task manager handles sync/async tasks
|
||||
*/
|
||||
@Override
|
||||
public TaskManager getTaskManager() {
|
||||
return new BukkitTaskMan(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getVersion() {
|
||||
try {
|
||||
final int[] version = new int[3];
|
||||
final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
||||
version[0] = Integer.parseInt(split[0]);
|
||||
version[1] = Integer.parseInt(split[1]);
|
||||
if (split.length == 3) {
|
||||
version[2] = Integer.parseInt(split[2]);
|
||||
}
|
||||
return version;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
this.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||
this.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The FaweQueue is a core part of block placement<br>
|
||||
* - The queue returned here is used in the SetQueue class (SetQueue handles the implementation specific queue)<br>
|
||||
* - Block changes are grouped by chunk (as it's more efficient for lighting/packet sending)<br>
|
||||
* - The FaweQueue returned here will provide the wrapper around the chunk object (FaweChunk)<br>
|
||||
* - When a block change is requested, the SetQueue will first check if the chunk exists in the queue, or it will create and add it<br>
|
||||
*/
|
||||
@Override
|
||||
public FaweQueue getQueue() {
|
||||
if (FaweAPI.checkVersion(this.getServerVersion(), 1, 9, 0)) {
|
||||
try {
|
||||
return new BukkitQueue_1_9();
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new BukkitQueue_1_8();
|
||||
}
|
||||
|
||||
private int[] version;
|
||||
|
||||
public int[] getServerVersion() {
|
||||
if (this.version == null) {
|
||||
try {
|
||||
this.version = new int[3];
|
||||
final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
||||
this.version[0] = Integer.parseInt(split[0]);
|
||||
this.version[1] = Integer.parseInt(split[1]);
|
||||
if (split.length == 3) {
|
||||
this.version[2] = Integer.parseInt(split[2]);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
||||
}
|
||||
}
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* The EditSessionWrapper should have the same functionality as the normal EditSessionWrapper but with some optimizations
|
||||
*/
|
||||
@Override
|
||||
public EditSessionWrapper getEditSessionWrapper(final EditSession session) {
|
||||
return new BukkitEditSessionWrapper_1_8(session);
|
||||
}
|
||||
|
||||
/**
|
||||
* A mask manager handles region restrictions e.g. PlotSquared plots / WorldGuard regions
|
||||
*/
|
||||
@Override
|
||||
public Collection<FaweMaskManager> getMaskManagers() {
|
||||
final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
final ArrayList<FaweMaskManager> managers = new ArrayList<>();
|
||||
if ((worldguardPlugin != null) && worldguardPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new Worldguard(worldguardPlugin, this));
|
||||
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'WorldGuard' not found. Worldguard features disabled.");
|
||||
}
|
||||
final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe");
|
||||
if ((plotmePlugin != null) && plotmePlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new PlotMeFeature(plotmePlugin, this));
|
||||
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'PlotMe' not found. PlotMe features disabled.");
|
||||
}
|
||||
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
|
||||
if ((townyPlugin != null) && townyPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new TownyFeature(townyPlugin, this));
|
||||
Fawe.debug("Plugin 'Towny' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'Towny' not found. Towny features disabled.");
|
||||
}
|
||||
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
|
||||
if ((factionsPlugin != null) && factionsPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new FactionsFeature(factionsPlugin, this));
|
||||
Fawe.debug("Plugin 'Factions' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
managers.add(new FactionsUUIDFeature(factionsPlugin, this));
|
||||
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'Factions' not found. Factions features disabled.");
|
||||
}
|
||||
final Plugin residencePlugin = Bukkit.getServer().getPluginManager().getPlugin("Residence");
|
||||
if ((residencePlugin != null) && residencePlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new ResidenceFeature(residencePlugin, this));
|
||||
Fawe.debug("Plugin 'Residence' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'Residence' not found. Factions features disabled.");
|
||||
}
|
||||
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
|
||||
if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
|
||||
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'GriefPrevention' not found. GriefPrevention features disabled.");
|
||||
}
|
||||
final Plugin plotsquaredPlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
||||
if ((plotsquaredPlugin != null) && plotsquaredPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new PlotSquaredFeature(plotsquaredPlugin, this));
|
||||
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'PlotSquared' not found. PlotSquared features disabled.");
|
||||
}
|
||||
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
|
||||
if ((preciousstonesPlugin != null) && preciousstonesPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
|
||||
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Fawe.debug("Plugin 'PreciousStones' not found. PreciousStones features disabled.");
|
||||
}
|
||||
return managers;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultUtil {
|
||||
public final Permission permission;
|
||||
|
||||
public VaultUtil() {
|
||||
final RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
this.permission = permissionProvider.getProvider();
|
||||
} else {
|
||||
this.permission = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,321 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.Perm;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
* Kinda a really messy class I just copied over from an old project<br>
|
||||
* - Still works, so cbf cleaning it up<br>
|
||||
* - Completely optional to have this class enabled since things get cancelled further down anyway<br>
|
||||
* - Useful since it informs the player why an edit changed no blocks etc.<br>
|
||||
* - Predicts the number of blocks changed and cancels the edit if it's too large<br>
|
||||
* - Predicts where the edit will effect and cancels it if it's outside a region<br>
|
||||
* - Restricts the brush iteration limit<br>
|
||||
* @deprecated as I plan on replacing it at some point
|
||||
*/
|
||||
@Deprecated
|
||||
public class WEListener implements Listener {
|
||||
|
||||
public final HashSet<String> rad1 = new HashSet<>(Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size"));
|
||||
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
||||
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
||||
public final HashSet<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid"));
|
||||
public final HashSet<String> rad2_3 = new HashSet<>(Arrays.asList("brush smooth"));
|
||||
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity"));
|
||||
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
||||
|
||||
public final HashSet<String> region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr",
|
||||
"copy", "cut", "green", "setbiome"));
|
||||
public final HashSet<String> regionExtend = new HashSet<>(Arrays.asList("stack"));
|
||||
public final HashSet<String> unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem"));
|
||||
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
|
||||
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
|
||||
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo", "schematic", "schem", "count"));
|
||||
|
||||
public boolean checkCommand(final List<String> list, final String cmd) {
|
||||
for (final String identifier : list) {
|
||||
if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String reduceCmd(final String cmd, final boolean single) {
|
||||
if (cmd.startsWith("/worldedit:/")) {
|
||||
return cmd.substring(12);
|
||||
}
|
||||
if (cmd.startsWith("/worldedit:")) {
|
||||
return cmd.substring(11);
|
||||
}
|
||||
if (cmd.startsWith("//")) {
|
||||
return cmd.substring(2);
|
||||
}
|
||||
if (single && cmd.startsWith("/")) {
|
||||
return cmd.substring(1);
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public int getInt(final String s) {
|
||||
try {
|
||||
int max = 0;
|
||||
final String[] split = s.split(",");
|
||||
for (final String rad : split) {
|
||||
final int val = Integer.parseInt(rad);
|
||||
if (val > max) {
|
||||
max = val;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
} catch (final NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkVolume(final FawePlayer<Player> player, final long volume, final long max, final Cancellable e) {
|
||||
if (volume > max) {
|
||||
MainUtil.sendMessage(FawePlayer.wrap(player.getName()), BBC.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + ""));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkSelection(final FawePlayer<Player> player, final int modifier, final long max, final Cancellable e) {
|
||||
final LocalSession session = Fawe.get().getWorldEdit().getSession(player.getName());
|
||||
final LocalWorld w = BukkitUtil.getLocalWorld(player.parent.getWorld());
|
||||
Region selection = null;
|
||||
try {
|
||||
selection = session.getSelection(w);
|
||||
} catch (final IncompleteRegionException e2) {}
|
||||
if (selection == null) {
|
||||
return true;
|
||||
}
|
||||
final BlockVector pos1 = selection.getMinimumPoint().toBlockVector();
|
||||
final BlockVector pos2 = selection.getMaximumPoint().toBlockVector();
|
||||
final HashSet<RegionWrapper> mask = WEManager.IMP.getMask(player);
|
||||
final RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
||||
if (Settings.REQUIRE_SELECTION) {
|
||||
String arg = null;
|
||||
if (!WEManager.IMP.regionContains(region, mask)) {
|
||||
arg = "pos1 + pos2";
|
||||
} else if (!WEManager.IMP.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) {
|
||||
arg = "pos1";
|
||||
} else if (!WEManager.IMP.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) {
|
||||
arg = "pos2";
|
||||
}
|
||||
if (arg != null) {
|
||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player, arg);
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!WEManager.IMP.regionContains(region, mask)) {
|
||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player, "pos1 + pos2");
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
|
||||
return this.checkVolume(player, volume, max, e);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) {
|
||||
final FawePlayer<Player> player = FawePlayer.wrap(e.getPlayer());
|
||||
final String message = e.getMessage();
|
||||
final String cmd = message.toLowerCase();
|
||||
final boolean single = true;
|
||||
final String[] split = cmd.split(" ");
|
||||
|
||||
final long maxVolume = Settings.WE_MAX_VOLUME;
|
||||
final long maxIterations = Settings.WE_MAX_ITERATIONS;
|
||||
// if (player.hasPermission("fawe.bypass")) {
|
||||
// return true;
|
||||
// }
|
||||
if (split.length >= 2) {
|
||||
final String reduced = this.reduceCmd(split[0], single);
|
||||
final String reduced2 = this.reduceCmd(split[0] + " " + split[1], single);
|
||||
if (this.rad1.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
final long volume = this.getInt(split[1]) * 256;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
if (this.rad2.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
final long volume = this.getInt(split[2]) * 256;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad2_1.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 4) {
|
||||
final long volume = this.getInt(split[2]) * this.getInt(split[3]);
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad2_2.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
final long radius = this.getInt(split[2]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad2_3.contains(reduced2)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
if (split.length == 4) {
|
||||
final int iterations = this.getInt(split[3]);
|
||||
if (iterations > maxIterations) {
|
||||
MainUtil.sendMessage(player, BBC.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + ""));
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final long radius = this.getInt(split[2]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad3_1.contains(reduced2)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
int i = 2;
|
||||
if (split[i].equalsIgnoreCase("-h")) {
|
||||
i = 3;
|
||||
}
|
||||
final long radius = this.getInt(split[i]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad3_2.contains(reduced2)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 4) {
|
||||
int i = 3;
|
||||
if (split[i].equalsIgnoreCase("-h")) {
|
||||
i = 4;
|
||||
}
|
||||
final long radius = this.getInt(split[i]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.regionExtend.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
return this.checkSelection(player, this.getInt(split[1]), maxVolume, e);
|
||||
}
|
||||
}
|
||||
final String reduced = this.reduceCmd(split[0], single);
|
||||
if (Settings.WE_BLACKLIST.contains(reduced)) {
|
||||
BBC.WORLDEDIT_UNSAFE.send(player);
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
}
|
||||
if (this.restricted.contains(reduced)) {
|
||||
final HashSet<RegionWrapper> mask = WEManager.IMP.getMask(player);
|
||||
final Location loc = player.parent.getLocation();
|
||||
for (final RegionWrapper region : mask) {
|
||||
if (region.isIn(loc.getBlockX(), loc.getBlockZ())) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player);
|
||||
return true;
|
||||
}
|
||||
if (this.region.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
return this.checkSelection(player, 1, maxVolume, e);
|
||||
}
|
||||
if (this.unregioned.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (this.other.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
|
||||
public abstract class BukkitMaskManager extends FaweMaskManager<Player> {
|
||||
|
||||
public BukkitMaskManager(final String plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin factions;
|
||||
|
||||
public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
||||
super(factionsPlugin.getName());
|
||||
this.factions = factionsPlugin;
|
||||
this.plugin = p3;
|
||||
BoardColl.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location loc = player.getLocation();
|
||||
final PS ps = PS.valueOf(loc);
|
||||
final Faction fac = BoardColl.get().getFactionAt(ps);
|
||||
if (fac != null) {
|
||||
if (fac.getOnlinePlayers().contains(player)) {
|
||||
if (fac.getComparisonName().equals("wilderness") == false) {
|
||||
final Chunk chunk = loc.getChunk();
|
||||
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.util.Perm;
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
|
||||
public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||
private final Board instance;
|
||||
|
||||
public FactionsUUIDFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
||||
super(factionsPlugin.getName());
|
||||
this.instance = Board.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Chunk chunk = player.getLocation().getChunk();
|
||||
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness");
|
||||
final RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());
|
||||
final World world = player.getWorld();
|
||||
|
||||
int count = 32;
|
||||
|
||||
if (this.isAdded(locs, world, player, perm)) {
|
||||
boolean hasPerm = true;
|
||||
|
||||
RegionWrapper chunkSelection;
|
||||
while (hasPerm && (count > 0)) {
|
||||
count--;
|
||||
|
||||
hasPerm = false;
|
||||
|
||||
chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
|
||||
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||
locs.maxX += 1;
|
||||
hasPerm = true;
|
||||
}
|
||||
|
||||
chunkSelection = new RegionWrapper(locs.minX - 1, locs.minX - 1, locs.minZ, locs.maxZ);
|
||||
|
||||
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||
locs.minX -= 1;
|
||||
hasPerm = true;
|
||||
}
|
||||
|
||||
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.maxZ + 1, locs.maxZ + 1);
|
||||
|
||||
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||
locs.maxZ += 1;
|
||||
hasPerm = true;
|
||||
}
|
||||
|
||||
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.minZ - 1, locs.minZ - 1);
|
||||
|
||||
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||
locs.minZ -= 1;
|
||||
hasPerm = true;
|
||||
}
|
||||
}
|
||||
|
||||
final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
|
||||
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAdded(final RegionWrapper locs, final World world, final Player player, final boolean perm) {
|
||||
for (int x = locs.minX; x <= locs.maxX; x++) {
|
||||
for (int z = locs.minZ; z <= locs.maxZ; z++) {
|
||||
final Faction fac = this.instance.getFactionAt(new FLocation(world.getName(), x, z));
|
||||
if (fac == null) {
|
||||
return false;
|
||||
}
|
||||
if (!fac.getOnlinePlayers().contains(player)) {
|
||||
return false;
|
||||
}
|
||||
if (fac.isWilderness() && !perm) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
|
||||
public class FaweMask {
|
||||
private String description = null;
|
||||
private Location position1;
|
||||
private Location position2;
|
||||
|
||||
public FaweMask(final Location pos1, final Location pos2, final String id) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("Locations cannot be null!");
|
||||
}
|
||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||
}
|
||||
this.description = id;
|
||||
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public FaweMask(final Location pos1, final Location pos2) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("Locations cannot be null!");
|
||||
}
|
||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||
}
|
||||
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public HashSet<RegionWrapper> getRegions() {
|
||||
final Location lower = this.getLowerBound();
|
||||
final Location upper = this.getUpperBound();
|
||||
return new HashSet<>(Arrays.asList(new RegionWrapper(lower.getBlockX(), upper.getBlockX(), lower.getBlockZ(), upper.getBlockZ())));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Location getLowerBound() {
|
||||
return this.position1;
|
||||
}
|
||||
|
||||
public Location getUpperBound() {
|
||||
return this.position2;
|
||||
}
|
||||
|
||||
public void setBounds(final Location pos1, final Location pos2) {
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
throw new IllegalArgumentException("Locations cannot be null!");
|
||||
}
|
||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||
}
|
||||
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||
}
|
||||
|
||||
public Location[] getBounds() {
|
||||
final Location[] locations = { this.position1, this.position2 };
|
||||
return locations;
|
||||
}
|
||||
|
||||
public boolean contains(final Location loc) {
|
||||
if (this.position1.getWorld().equals(loc.getWorld())) {
|
||||
if (loc.getBlockX() < this.position1.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockX() > this.position2.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockZ() < this.position1.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockZ() > this.position2.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockY() < this.position1.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
if (loc.getBlockY() > this.position2.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
|
||||
public class GriefPreventionFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin griefprevention;
|
||||
|
||||
public GriefPreventionFeature(final Plugin griefpreventionPlugin, final FaweBukkit p3) {
|
||||
super(griefpreventionPlugin.getName());
|
||||
this.griefprevention = griefpreventionPlugin;
|
||||
this.plugin = p3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
|
||||
if (claim != null) {
|
||||
final String uuid = player.getUniqueId().toString();
|
||||
if (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerName().equals(uuid)) {
|
||||
claim.getGreaterBoundaryCorner().getBlockX();
|
||||
final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CLAIM:" + claim.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.worldcretornica.plotme_core.Plot;
|
||||
import com.worldcretornica.plotme_core.PlotMe_Core;
|
||||
import com.worldcretornica.plotme_core.bukkit.PlotMe_CorePlugin;
|
||||
import com.worldcretornica.plotme_core.bukkit.api.BukkitPlayer;
|
||||
import com.worldcretornica.plotme_core.bukkit.api.BukkitWorld;
|
||||
|
||||
public class PlotMeFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
PlotMe_Core plotme;
|
||||
|
||||
public PlotMeFeature(final Plugin plotmePlugin, final FaweBukkit p3) {
|
||||
super(plotmePlugin.getName());
|
||||
this.plotme = ((PlotMe_CorePlugin) plotmePlugin).getAPI();
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final Plot plot = this.plotme.getPlotMeCoreManager().getPlotById(new BukkitPlayer(player));
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
final boolean isallowed = plot.isAllowed(player.getUniqueId());
|
||||
if (isallowed) {
|
||||
final Location pos1 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).bottomX(plot.getId(), new BukkitWorld(player.getWorld())), 0, this.plotme
|
||||
.getGenManager(player.getWorld().getName()).bottomZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||
final Location pos2 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).topX(plot.getId(), new BukkitWorld(player.getWorld())), 256, this.plotme
|
||||
.getGenManager(player.getWorld().getName()).topZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return plot.getId();
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
|
||||
public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
|
||||
public PlotSquaredFeature(final Plugin plotPlugin, final FaweBukkit p3) {
|
||||
super(plotPlugin.getName());
|
||||
this.plugin = p3;
|
||||
BukkitMain.worldEdit = null;
|
||||
PS.get().worldedit = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final PlotPlayer pp = PlotPlayer.wrap(fp.parent);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
final com.intellectualcrafters.plot.object.Location loc = pp.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
int min = Integer.MAX_VALUE;
|
||||
for (final Plot p : pp.getPlots()) {
|
||||
if (p.getArea().worldname.equals(world)) {
|
||||
final double d = p.getHome().getEuclideanDistanceSquared(loc);
|
||||
if (d < min) {
|
||||
min = (int) d;
|
||||
plot = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot != null) {
|
||||
final PlotId id = plot.getId();
|
||||
boolean hasPerm = false;
|
||||
if (plot.owner != null) {
|
||||
if (plot.owner.equals(pp.getUUID())) {
|
||||
hasPerm = true;
|
||||
} else if (plot.isAdded(pp.getUUID()) && pp.hasPermission("fawe.plotsquared.member")) {
|
||||
hasPerm = true;
|
||||
}
|
||||
if (hasPerm) {
|
||||
final World world = fp.parent.getWorld();
|
||||
final com.intellectualcrafters.plot.object.RegionWrapper region = plot.getLargestRegion();
|
||||
final HashSet<com.intellectualcrafters.plot.object.RegionWrapper> regions = plot.getRegions();
|
||||
|
||||
final Location pos1 = new Location(world, region.minX, 0, region.minZ);
|
||||
final Location pos2 = new Location(world, region.maxX, 256, region.maxZ);
|
||||
|
||||
final HashSet<RegionWrapper> faweRegions = new HashSet<RegionWrapper>();
|
||||
for (final com.intellectualcrafters.plot.object.RegionWrapper current : regions) {
|
||||
faweRegions.add(new RegionWrapper(current.minX, current.maxX, current.minZ, current.maxZ));
|
||||
}
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PLOT^2:" + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<RegionWrapper> getRegions() {
|
||||
return faweRegions;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.vectors.Field;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
|
||||
public class PreciousStonesFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin preciousstones;
|
||||
|
||||
public PreciousStonesFeature(final Plugin preciousstonesPlugin, final FaweBukkit p3) {
|
||||
super(preciousstonesPlugin.getName());
|
||||
this.preciousstones = preciousstonesPlugin;
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.PLOT, location);
|
||||
for (final Field myfield : fields) {
|
||||
if (myfield.getOwner().equalsIgnoreCase(player.getName()) || (myfield.getAllowed().contains(player.getName()))) {
|
||||
final Location pos1 = new Location(location.getWorld(), myfield.getCorners().get(0).getBlockX(), myfield.getCorners().get(0).getBlockY(), myfield.getCorners().get(0).getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), myfield.getCorners().get(1).getBlockX(), myfield.getCorners().get(1).getBlockY(), myfield.getCorners().get(1).getBlockZ());
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FIELD:" + myfield.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.CuboidArea;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
|
||||
public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin residence;
|
||||
|
||||
public ResidenceFeature(final Plugin residencePlugin, final FaweBukkit p3) {
|
||||
super(residencePlugin.getName());
|
||||
this.residence = residencePlugin;
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final ClaimedResidence residence = Residence.getResidenceManager().getByLoc(location);
|
||||
if (residence != null) {
|
||||
if (residence.getPlayersInResidence().contains(player)) {
|
||||
final CuboidArea area = residence.getAreaArray()[0];
|
||||
final Location pos1 = area.getHighLoc();
|
||||
final Location pos2 = area.getLowLoc();
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RESIDENCE: " + residence.getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.palmergames.bukkit.towny.object.PlayerCache;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
|
||||
public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin towny;
|
||||
|
||||
public TownyFeature(final Plugin townyPlugin, final FaweBukkit p3) {
|
||||
super(townyPlugin.getName());
|
||||
this.towny = townyPlugin;
|
||||
this.plugin = p3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
try {
|
||||
final PlayerCache cache = ((Towny) this.towny).getCache(player);
|
||||
final WorldCoord mycoord = cache.getLastTownBlock();
|
||||
if (mycoord == null) {
|
||||
return null;
|
||||
} else {
|
||||
final TownBlock myplot = mycoord.getTownBlock();
|
||||
if (myplot == null) {
|
||||
return null;
|
||||
} else {
|
||||
boolean isMember = false;
|
||||
try {
|
||||
if (myplot.getResident().getName().equals(player.getName())) {
|
||||
isMember = true;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
if (!isMember) {
|
||||
if (player.hasPermission("fawe.towny.*")) {
|
||||
isMember = true;
|
||||
} else if (myplot.getTown().isMayor(TownyUniverse.getDataSource().getResident(player.getName()))) {
|
||||
isMember = true;
|
||||
}
|
||||
}
|
||||
if (isMember) {
|
||||
final Chunk chunk = location.getChunk();
|
||||
final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PLOT:" + location.getChunk().getX() + "," + location.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
WorldGuardPlugin worldguard;
|
||||
FaweBukkit plugin;
|
||||
|
||||
private WorldGuardPlugin getWorldGuard() {
|
||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
|
||||
// WorldGuard may not be loaded
|
||||
if ((plugin == null) || !(plugin instanceof WorldGuardPlugin)) {
|
||||
return null; // Maybe you want throw an exception instead
|
||||
}
|
||||
|
||||
return (WorldGuardPlugin) plugin;
|
||||
}
|
||||
|
||||
public Worldguard(final Plugin p2, final FaweBukkit p3) {
|
||||
super(p2.getName());
|
||||
this.worldguard = this.getWorldGuard();
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
|
||||
public ProtectedRegion isowner(final Player player, final Location location) {
|
||||
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final RegionManager manager = this.worldguard.getRegionManager(player.getWorld());
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (region.isOwner(localplayer)) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().equals(player.getName().toLowerCase())) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().contains(player.getName().toLowerCase() + "//")) {
|
||||
return region;
|
||||
} else if (region.isOwner("*")) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProtectedRegion getregion(final Player player, final BlockVector location) {
|
||||
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final ApplicableRegionSet regions = this.worldguard.getRegionManager(player.getWorld()).getApplicableRegions(location);
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (region.isOwner(localplayer)) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().equals(player.getName().toLowerCase())) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().contains(player.getName().toLowerCase() + "//")) {
|
||||
return region;
|
||||
} else if (region.isOwner("*")) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final ProtectedRegion myregion = this.isowner(player, location);
|
||||
if (myregion != null) {
|
||||
final Location pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return myregion.getId();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import com.boydti.fawe.logging.BlocksHubHook;
|
||||
import com.boydti.fawe.object.EditSessionWrapper;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
|
||||
public class BukkitEditSessionWrapper_0 extends EditSessionWrapper {
|
||||
|
||||
private BlocksHubHook hook;
|
||||
|
||||
public BukkitEditSessionWrapper_0(final EditSession session) {
|
||||
super(session);
|
||||
try {
|
||||
// Try to hook into BlocksHub
|
||||
this.hook = new BlocksHubHook();
|
||||
} catch (final Throwable e) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent getHistoryExtent(final Extent parent, final ChangeSet set, final FawePlayer<?> player) {
|
||||
if (this.hook != null) {
|
||||
// If we are doing logging, return a custom logging extent
|
||||
return this.hook.getLoggingExtent(parent, set, player);
|
||||
}
|
||||
// Otherwise return the normal history extent
|
||||
return super.getHistoryExtent(parent, set, player);
|
||||
}
|
||||
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.util.FaweQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
/**
|
||||
* The base object for
|
||||
*/
|
||||
public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
|
||||
/**
|
||||
* Map of loaded chunks for quicker checking
|
||||
*/
|
||||
private final HashMap<String, HashSet<Long>> loaded = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Map of chunks in the queue
|
||||
*/
|
||||
private final ConcurrentHashMap<ChunkLoc, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
|
||||
|
||||
public BukkitQueue_0() {
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getPluginManager().registerEvents(BukkitQueue_0.this, (Plugin) Fawe.imp());
|
||||
}
|
||||
});
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
this.addLoaded(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onWorldLoad(final WorldLoadEvent event) {
|
||||
final World world = event.getWorld();
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
this.addLoaded(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onWorldUnload(final WorldUnloadEvent event) {
|
||||
this.loaded.remove(event.getWorld().getName());
|
||||
}
|
||||
|
||||
public void addLoaded(final Chunk chunk) {
|
||||
final String world = chunk.getWorld().getName();
|
||||
final long x = chunk.getX();
|
||||
final long z = chunk.getZ();
|
||||
final long id = (x << 32) | (z & 0xFFFFFFFFL);
|
||||
HashSet<Long> map = this.loaded.get(world);
|
||||
if (map != null) {
|
||||
map.add(id);
|
||||
} else {
|
||||
map = new HashSet<>(Arrays.asList(id));
|
||||
this.loaded.put(world, map);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeLoaded(final Chunk chunk) {
|
||||
final String world = chunk.getWorld().getName();
|
||||
final long x = chunk.getX();
|
||||
final long z = chunk.getZ();
|
||||
final long id = (x << 32) | (z & 0xFFFFFFFFL);
|
||||
final HashSet<Long> map = this.loaded.get(world);
|
||||
if (map != null) {
|
||||
map.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(final String world, final int x, final int z) {
|
||||
final long id = ((long) x << 32) | (z & 0xFFFFFFFFL);
|
||||
final HashSet<Long> map = this.loaded.get(world);
|
||||
if (map != null) {
|
||||
return map.contains(id);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onChunkLoad(final ChunkLoadEvent event) {
|
||||
final Chunk chunk = event.getChunk();
|
||||
this.addLoaded(chunk);
|
||||
if (Settings.FIX_ALL_LIGHTING) {
|
||||
this.fixLighting(this.getChunk(new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ())), false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onChunkUnload(final ChunkUnloadEvent event) {
|
||||
this.removeLoaded(event.getChunk());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(String world, int x, int y, int z, Runnable runnable) {
|
||||
// TODO Auto-generated method stub
|
||||
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
||||
FaweChunk<Chunk> result = this.blocks.get(wrap);
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("Task must be accompanied by a block change or manually adding to queue!");
|
||||
}
|
||||
result.addTask(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(final String world, int x, final int y, int z, final short id, final byte data) {
|
||||
if ((y > 255) || (y < 0)) {
|
||||
return false;
|
||||
}
|
||||
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
||||
x = x & 15;
|
||||
z = z & 15;
|
||||
FaweChunk<Chunk> result = this.blocks.get(wrap);
|
||||
if (result == null) {
|
||||
result = this.getChunk(wrap);
|
||||
result.setBlock(x, y, z, id, data);
|
||||
final FaweChunk<Chunk> previous = this.blocks.put(wrap, result);
|
||||
if (previous == null) {
|
||||
return true;
|
||||
}
|
||||
this.blocks.put(wrap, previous);
|
||||
result = previous;
|
||||
}
|
||||
result.setBlock(x, y, z, id, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final String world, int x, int z, final BaseBiome biome) {
|
||||
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
||||
x = x & 15;
|
||||
z = z & 15;
|
||||
FaweChunk<Chunk> result = this.blocks.get(wrap);
|
||||
if (result == null) {
|
||||
result = this.getChunk(wrap);
|
||||
final FaweChunk<Chunk> previous = this.blocks.put(wrap, result);
|
||||
if (previous != null) {
|
||||
this.blocks.put(wrap, previous);
|
||||
result = previous;
|
||||
}
|
||||
}
|
||||
result.setBiome(x, z, biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweChunk<Chunk> next() {
|
||||
try {
|
||||
if (this.blocks.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
final Iterator<Entry<ChunkLoc, FaweChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
|
||||
final FaweChunk<Chunk> toReturn = iter.next().getValue();
|
||||
if (SetQueue.IMP.isWaiting()) {
|
||||
return null;
|
||||
}
|
||||
iter.remove();
|
||||
this.execute(toReturn);
|
||||
return toReturn;
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final ArrayDeque<FaweChunk<Chunk>> toUpdate = new ArrayDeque<>();
|
||||
|
||||
public boolean execute(final FaweChunk<Chunk> fc) {
|
||||
if (fc == null) {
|
||||
return false;
|
||||
}
|
||||
// Load chunk
|
||||
final Chunk chunk = fc.getChunk();
|
||||
chunk.load(true);
|
||||
// Set blocks / entities / biome
|
||||
if (!this.setComponents(fc)) {
|
||||
return false;
|
||||
}
|
||||
fc.executeTasks();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.blocks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunk(final FaweChunk<?> chunk) {
|
||||
this.blocks.put(chunk.getChunkLoc(), (FaweChunk<Chunk>) chunk);
|
||||
}
|
||||
|
||||
public abstract Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs);
|
||||
|
||||
public abstract boolean setComponents(final FaweChunk<Chunk> fc);
|
||||
|
||||
@Override
|
||||
public abstract FaweChunk<Chunk> getChunk(final ChunkLoc wrap);
|
||||
|
||||
@Override
|
||||
public abstract boolean fixLighting(final FaweChunk<?> fc, final boolean fixAll);
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_8;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
||||
|
||||
private char[][] ids;
|
||||
|
||||
private final short[] count;
|
||||
private final short[] air;
|
||||
private final short[] relight;
|
||||
private int[][] biomes;
|
||||
|
||||
public Chunk chunk;
|
||||
|
||||
/**
|
||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||
*/
|
||||
protected BukkitChunk_1_8(final ChunkLoc chunk) {
|
||||
super(chunk);
|
||||
this.ids = new char[16][];
|
||||
this.count = new short[16];
|
||||
this.air = new short[16];
|
||||
this.relight = new short[16];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
if (this.chunk == null) {
|
||||
final ChunkLoc cl = this.getChunkLoc();
|
||||
this.chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||
}
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkLoc(final ChunkLoc loc) {
|
||||
super.setChunkLoc(loc);
|
||||
this.chunk = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of block changes in a specified section
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getCount(final int i) {
|
||||
return this.count[i];
|
||||
}
|
||||
|
||||
public int getAir(final int i) {
|
||||
return this.air[i];
|
||||
}
|
||||
|
||||
public void setCount(final int i, final short value) {
|
||||
this.count[i] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of block changes in a specified section
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getRelight(final int i) {
|
||||
return this.relight[i];
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += this.count[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getTotalRelight() {
|
||||
if ((this.getTotalCount() == 0) && (this.biomes == null)) {
|
||||
Arrays.fill(this.count, (short) 1);
|
||||
Arrays.fill(this.relight, Short.MAX_VALUE);
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += this.relight[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw data for a section
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public char[] getIdArray(final int i) {
|
||||
return this.ids[i];
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.ids = null;
|
||||
this.biomes = null;
|
||||
}
|
||||
|
||||
public int[][] getBiomeArray() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
||||
final int i = FaweCache.CACHE_I[y][x][z];
|
||||
final int j = FaweCache.CACHE_J[y][x][z];
|
||||
char[] vs = this.ids[i];
|
||||
if (vs == null) {
|
||||
vs = this.ids[i] = new char[4096];
|
||||
this.count[i]++;
|
||||
} else if (vs[j] == 0) {
|
||||
this.count[i]++;
|
||||
}
|
||||
switch (id) {
|
||||
case 0:
|
||||
this.air[i]++;
|
||||
vs[j] = (char) 1;
|
||||
return;
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 51:
|
||||
case 74:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 138:
|
||||
case 169:
|
||||
this.relight[i]++;
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 73:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192:
|
||||
vs[j] = (char) (id << 4);
|
||||
return;
|
||||
case 130:
|
||||
case 76:
|
||||
case 62:
|
||||
this.relight[i]++;
|
||||
case 54:
|
||||
case 146:
|
||||
case 61:
|
||||
case 65:
|
||||
case 68:
|
||||
case 50:
|
||||
if (data < 2) {
|
||||
data = 2;
|
||||
}
|
||||
default:
|
||||
vs[j] = (char) ((id << 4) + data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(final int x, final int z, final BaseBiome biome) {
|
||||
if (this.biomes == null) {
|
||||
this.biomes = new int[16][];
|
||||
}
|
||||
int[] index = this.biomes[x];
|
||||
if (index == null) {
|
||||
index = this.biomes[x] = new int[16];
|
||||
}
|
||||
index[z] = biome.getId();
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_8;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.boydti.fawe.bukkit.v0.BukkitEditSessionWrapper_0;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefClass;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefField;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefMethod;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
public class BukkitEditSessionWrapper_1_8 extends BukkitEditSessionWrapper_0 {
|
||||
|
||||
private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||
|
||||
private RefMethod worldGetHandle;
|
||||
private RefMethod methodGetChunkAt;
|
||||
private RefField heightMap;
|
||||
private Object nmsWorld;
|
||||
|
||||
private int lastXMin;
|
||||
private int lastZMin;
|
||||
private Object lastChunk;
|
||||
|
||||
public BukkitEditSessionWrapper_1_8(final EditSession session) {
|
||||
super(session);
|
||||
try {
|
||||
this.worldGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
this.heightMap = this.classChunk.getField("heightMap");
|
||||
this.nmsWorld = this.worldGetHandle.of(Bukkit.getWorld(session.getWorld().getName())).call();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestTerrainBlock(final int x, final int z, final int minY, final int maxY, final boolean naturalOnly) {
|
||||
final int bx = x >> 4;
|
||||
final int bz = z >> 4;
|
||||
int[] heights;
|
||||
if ((this.lastChunk == null) || (bx != this.lastXMin) || (bz != this.lastZMin)) {
|
||||
this.lastXMin = bx;
|
||||
this.lastZMin = bz;
|
||||
this.lastChunk = this.methodGetChunkAt.of(this.nmsWorld).call(bx, bz);
|
||||
}
|
||||
if (this.lastChunk != null) {
|
||||
heights = (int[]) this.heightMap.of(this.lastChunk).get();
|
||||
final int lx = x & 15;
|
||||
final int lz = z & 15;
|
||||
final int height = heights[((lz << 4) | lx)];
|
||||
if ((height <= maxY) && (height >= minY)) {
|
||||
final Vector pt = new Vector(x, height, z);
|
||||
final int id = this.session.getBlockType(pt);
|
||||
if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, 0) : !BlockType.canPassThrough(id, 0)) {
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
final Vector pt = new Vector(x, y, z);
|
||||
final int id = this.session.getBlockType(pt);
|
||||
int data;
|
||||
switch (id) {
|
||||
case 0: {
|
||||
continue;
|
||||
}
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 25:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 51:
|
||||
case 52:
|
||||
case 54:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 61:
|
||||
case 62:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 73:
|
||||
case 74:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 84:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 117:
|
||||
case 121:
|
||||
case 122:
|
||||
case 123:
|
||||
case 124:
|
||||
case 129:
|
||||
case 133:
|
||||
case 138:
|
||||
case 137:
|
||||
case 140:
|
||||
case 165:
|
||||
case 166:
|
||||
case 169:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 176:
|
||||
case 177:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192:
|
||||
return y;
|
||||
default:
|
||||
data = 0;
|
||||
}
|
||||
if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, data) : !BlockType.canPassThrough(id, data)) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
return minY;
|
||||
}
|
||||
|
||||
}
|
@ -1,690 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_8;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.IntegerPair;
|
||||
import com.boydti.fawe.util.MemUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefClass;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefConstructor;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefField;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefMethod;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
||||
|
||||
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
||||
private final RefClass classConnection = getRefClass("{nms}.PlayerConnection");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||
private final RefField mustSave = this.classChunk.getField("mustSave");
|
||||
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
|
||||
private RefMethod methodGetHandlePlayer;
|
||||
private RefMethod methodGetHandleChunk;
|
||||
private RefConstructor MapChunk;
|
||||
private RefField connection;
|
||||
private RefMethod send;
|
||||
private RefMethod methodInitLighting;
|
||||
private RefConstructor classBlockPositionConstructor;
|
||||
private RefConstructor classChunkSectionConstructor;
|
||||
private RefMethod methodX;
|
||||
private RefMethod methodAreNeighborsLoaded;
|
||||
private RefField fieldSections;
|
||||
private RefField fieldWorld;
|
||||
private RefMethod methodGetIdArray;
|
||||
private RefMethod methodGetWorld;
|
||||
private RefField tileEntityListTick;
|
||||
|
||||
private final HashMap<String, FaweGenerator_1_8> worldMap = new HashMap<>();
|
||||
|
||||
public BukkitQueue_1_8() {
|
||||
try {
|
||||
this.methodGetHandlePlayer = this.classCraftPlayer.getMethod("getHandle");
|
||||
this.methodGetHandleChunk = this.classCraftChunk.getMethod("getHandle");
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.MapChunk = this.classMapChunk.getConstructor(this.classChunk.getRealClass(), boolean.class, int.class);
|
||||
this.connection = this.classEntityPlayer.getField("playerConnection");
|
||||
this.send = this.classConnection.getMethod("sendPacket", this.classPacket.getRealClass());
|
||||
this.classBlockPositionConstructor = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
this.methodX = this.classWorld.getMethod("x", this.classBlockPosition.getRealClass());
|
||||
this.fieldSections = this.classChunk.getField("sections");
|
||||
this.fieldWorld = this.classChunk.getField("world");
|
||||
this.methodGetIdArray = this.classChunkSection.getMethod("getIdArray");
|
||||
this.methodAreNeighborsLoaded = this.classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||
this.classChunkSectionConstructor = this.classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
this.tileEntityListTick = this.classWorld.getField("tileEntityList");
|
||||
this.methodGetWorld = this.classChunk.getMethod("getWorld");
|
||||
} catch (final NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public FaweGenerator_1_8 getFaweGenerator(final World world) {
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
if ((gen != null) && (gen instanceof FaweGenerator_1_8)) {
|
||||
return (FaweGenerator_1_8) gen;
|
||||
}
|
||||
FaweGenerator_1_8 faweGen = this.worldMap.get(world.getName());
|
||||
if (faweGen != null) {
|
||||
return faweGen;
|
||||
}
|
||||
faweGen = new FaweGenerator_1_8(this, world);
|
||||
this.worldMap.put(world.getName(), faweGen);
|
||||
return faweGen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs) {
|
||||
final HashMap<FaweChunk<Chunk>, Object> packets = new HashMap<>();
|
||||
final HashMap<String, ArrayList<FaweChunk<Chunk>>> map = new HashMap<>();
|
||||
|
||||
for (final FaweChunk<Chunk> fc : fcs) {
|
||||
final String world = fc.getChunkLoc().world;
|
||||
ArrayList<FaweChunk<Chunk>> list = map.get(world);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
map.put(world, list);
|
||||
}
|
||||
list.add(fc);
|
||||
}
|
||||
final int view = Bukkit.getServer().getViewDistance();
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
final String world = player.getWorld().getName();
|
||||
final ArrayList<FaweChunk<Chunk>> list = map.get(world);
|
||||
if (list == null) {
|
||||
continue;
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final int cx = loc.getBlockX() >> 4;
|
||||
final int cz = loc.getBlockZ() >> 4;
|
||||
final Object entity = this.methodGetHandlePlayer.of(player).call();
|
||||
|
||||
for (final FaweChunk<Chunk> fc : list) {
|
||||
final int dx = Math.abs(cx - fc.getChunkLoc().x);
|
||||
final int dz = Math.abs(cz - fc.getChunkLoc().z);
|
||||
if ((dx > view) || (dz > view)) {
|
||||
continue;
|
||||
}
|
||||
final RefExecutor con = this.send.of(this.connection.of(entity).get());
|
||||
Object packet = packets.get(fc);
|
||||
if (packet == null) {
|
||||
final Object c = this.methodGetHandleChunk.of(fc.getChunk()).call();
|
||||
packet = this.MapChunk.create(c, true, 65535);
|
||||
packets.put(fc, packet);
|
||||
con.call(packet);
|
||||
} else {
|
||||
con.call(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashSet<FaweChunk<Chunk>> chunks = new HashSet<FaweChunk<Chunk>>();
|
||||
for (final FaweChunk<Chunk> fc : fcs) {
|
||||
final Chunk chunk = fc.getChunk();
|
||||
chunk.unload(true, false);
|
||||
chunk.load();
|
||||
final ChunkLoc loc = fc.getChunkLoc();
|
||||
chunk.getWorld().refreshChunk(loc.x, loc.z);
|
||||
if (!this.fixLighting(fc, Settings.FIX_ALL_LIGHTING)) {
|
||||
chunks.add(fc);
|
||||
}
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fixLighting(final FaweChunk<?> fc, final boolean fixAll) {
|
||||
try {
|
||||
final BukkitChunk_1_8 bc = (BukkitChunk_1_8) fc;
|
||||
final Chunk chunk = bc.getChunk();
|
||||
if (!chunk.isLoaded()) {
|
||||
chunk.load(false);
|
||||
}
|
||||
|
||||
// Initialize lighting
|
||||
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
|
||||
this.methodInitLighting.of(c).call();
|
||||
|
||||
if (((bc.getTotalRelight() == 0) && !fixAll)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||
final Object w = this.fieldWorld.of(c).get();
|
||||
|
||||
final int X = chunk.getX() << 4;
|
||||
final int Z = chunk.getZ() << 4;
|
||||
|
||||
final RefExecutor relight = this.methodX.of(w);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
final Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if (((bc.getRelight(j) == 0) && !fixAll) || (bc.getCount(j) == 0) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0))) {
|
||||
continue;
|
||||
}
|
||||
final char[] array = this.getIdArray(section);
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
int l = FaweCache.RANDOM.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
final int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
final short id = FaweCache.CACHE_ID[i];
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if (!fixAll) {
|
||||
continue;
|
||||
}
|
||||
if ((k & 1) == l) {
|
||||
l = 1 - l;
|
||||
continue;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 50:
|
||||
case 51:
|
||||
case 62:
|
||||
case 74:
|
||||
case 76:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
final int x = FaweCache.CACHE_X[j][k];
|
||||
final int y = FaweCache.CACHE_Y[j][k];
|
||||
final int z = FaweCache.CACHE_Z[j][k];
|
||||
if (this.isSurrounded(sections, x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
final Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
relight.call(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSurrounded(final Object[] sections, final int x, final int y, final int z) {
|
||||
return this.isSolid(this.getId(sections, x, y + 1, z))
|
||||
&& this.isSolid(this.getId(sections, x + 1, y - 1, z))
|
||||
&& this.isSolid(this.getId(sections, x - 1, y, z))
|
||||
&& this.isSolid(this.getId(sections, x, y, z + 1))
|
||||
&& this.isSolid(this.getId(sections, x, y, z - 1));
|
||||
}
|
||||
|
||||
public boolean isSolid(final int i) {
|
||||
if (i == 0) {
|
||||
return false;
|
||||
}
|
||||
return Material.getMaterial(i).isOccluding();
|
||||
}
|
||||
|
||||
public int getId(final Object[] sections, final int x, final int y, final int z) {
|
||||
if ((x < 0) || (x > 15) || (z < 0) || (z > 15)) {
|
||||
return 1;
|
||||
}
|
||||
if ((y < 0) || (y > 255)) {
|
||||
return 1;
|
||||
}
|
||||
final int i = FaweCache.CACHE_I[y][x][z];
|
||||
final Object section = sections[i];
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
final char[] array = this.getIdArray(section);
|
||||
final int j = FaweCache.CACHE_J[y][x][z];
|
||||
return array[j] >> 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setComponents(final FaweChunk<Chunk> fc) {
|
||||
try {
|
||||
final BukkitChunk_1_8 fs = ((BukkitChunk_1_8) fc);
|
||||
final Chunk chunk = fs.getChunk();
|
||||
final World world = chunk.getWorld();
|
||||
|
||||
final boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||
|
||||
// Sections
|
||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
final Object c = getHandele.invoke(chunk);
|
||||
final Object w = this.methodGetWorld.of(c).call();
|
||||
final Class<? extends Object> clazz = c.getClass();
|
||||
final Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
final Field tf = clazz.getDeclaredField("tileEntities");
|
||||
final Field ef = clazz.getDeclaredField("entitySlices");
|
||||
|
||||
final Object[] sections = (Object[]) sf.get(c);
|
||||
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
final Collection<?>[] entities = (Collection<?>[]) ef.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
|
||||
// Trim tiles
|
||||
boolean removed = false;
|
||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Entry<?, ?> tile = iter.next();
|
||||
final Object pos = tile.getKey();
|
||||
if (xm == null) {
|
||||
final Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
|
||||
xm = clazz2.getDeclaredMethod("getX");
|
||||
ym = clazz2.getDeclaredMethod("getY");
|
||||
zm = clazz2.getDeclaredMethod("getZ");
|
||||
}
|
||||
final int lx = (int) xm.invoke(pos) & 15;
|
||||
final int ly = (int) ym.invoke(pos);
|
||||
final int lz = (int) zm.invoke(pos) & 15;
|
||||
final int j = FaweCache.CACHE_I[ly][lx][lz];
|
||||
final int k = FaweCache.CACHE_J[ly][lx][lz];
|
||||
final char[] array = fs.getIdArray(j);
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
if (array[k] != 0) {
|
||||
removed = true;
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
if (removed) {
|
||||
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
||||
}
|
||||
|
||||
// Trim entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((entities[i] != null) && (fs.getCount(i) >= 4096)) {
|
||||
entities[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Efficiently merge sections
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
if (fs.getCount(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
final char[] newArray = fs.getIdArray(j);
|
||||
if (newArray == null) {
|
||||
continue;
|
||||
}
|
||||
Object section = sections[j];
|
||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||
section = sections[j] = this.newChunkSection(j << 4, flag, newArray);
|
||||
continue;
|
||||
}
|
||||
final char[] currentArray = this.getIdArray(section);
|
||||
boolean fill = true;
|
||||
for (int k = 0; k < newArray.length; k++) {
|
||||
final char n = newArray[k];
|
||||
if (n == 0) {
|
||||
fill = false;
|
||||
continue;
|
||||
}
|
||||
switch (n) {
|
||||
case 0:
|
||||
fill = false;
|
||||
continue;
|
||||
case 1:
|
||||
fill = false;
|
||||
currentArray[k] = 0;
|
||||
continue;
|
||||
default:
|
||||
currentArray[k] = n;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (fill) {
|
||||
fs.setCount(j, Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Biomes
|
||||
final int[][] biomes = fs.getBiomeArray();
|
||||
if (biomes != null) {
|
||||
final LocalWorld lw = BukkitUtil.getLocalWorld(world);
|
||||
final int X = fs.getChunkLoc().x << 4;
|
||||
final int Z = fs.getChunkLoc().z << 4;
|
||||
final BaseBiome bb = new BaseBiome(0);
|
||||
int last = 0;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
final int[] array = biomes[x];
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
for (int z = 0; z < 16; z++) {
|
||||
final int biome = array[z];
|
||||
if (biome == 0) {
|
||||
continue;
|
||||
}
|
||||
if (last != biome) {
|
||||
last = biome;
|
||||
bb.setId(biome);
|
||||
}
|
||||
lw.setBiome(new Vector2D(X + x, Z + z), bb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear
|
||||
fs.clear();
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the server is < 1% available memory (i.e. likely to crash)<br>
|
||||
* - You can disable this in the conifg<br>
|
||||
* - Will try to free up some memory<br>
|
||||
* - Clears the queue<br>
|
||||
* - Clears worldedit history<br>
|
||||
* - Clears entities<br>
|
||||
* - Unloads chunks in vacant worlds<br>
|
||||
* - Unloads non visible chunks<br>
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
// Clear the queue
|
||||
super.clear();
|
||||
ArrayDeque<Chunk> toUnload = new ArrayDeque<>();
|
||||
final int distance = Bukkit.getViewDistance() + 2;
|
||||
HashMap<String, HashMap<IntegerPair, Integer>> players = new HashMap<>();
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
// Clear history
|
||||
final FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||
final LocalSession s = fp.getSession();
|
||||
if (s != null) {
|
||||
s.clearHistory();
|
||||
s.setClipboard(null);
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final World worldObj = loc.getWorld();
|
||||
final String world = worldObj.getName();
|
||||
HashMap<IntegerPair, Integer> map = players.get(world);
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
players.put(world, map);
|
||||
}
|
||||
final IntegerPair origin = new IntegerPair(loc.getBlockX() >> 4, loc.getBlockZ() >> 4);
|
||||
Integer val = map.get(origin);
|
||||
int check;
|
||||
if (val != null) {
|
||||
if (val == distance) {
|
||||
continue;
|
||||
}
|
||||
check = distance - val;
|
||||
} else {
|
||||
check = distance;
|
||||
map.put(origin, distance);
|
||||
}
|
||||
for (int x = -distance; x <= distance; x++) {
|
||||
if ((x >= check) || (-x >= check)) {
|
||||
continue;
|
||||
}
|
||||
for (int z = -distance; z <= distance; z++) {
|
||||
if ((z >= check) || (-z >= check)) {
|
||||
continue;
|
||||
}
|
||||
final int weight = distance - Math.max(Math.abs(x), Math.abs(z));
|
||||
final IntegerPair chunk = new IntegerPair(x + origin.x, z + origin.z);
|
||||
val = map.get(chunk);
|
||||
if ((val == null) || (val < weight)) {
|
||||
map.put(chunk, weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Fawe.get().getWorldEdit().clearSessions();
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
final String name = world.getName();
|
||||
final HashMap<IntegerPair, Integer> map = players.get(name);
|
||||
if ((map == null) || (map.size() == 0)) {
|
||||
final boolean save = world.isAutoSave();
|
||||
world.setAutoSave(false);
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
this.unloadChunk(name, chunk);
|
||||
}
|
||||
world.setAutoSave(save);
|
||||
continue;
|
||||
}
|
||||
final Chunk[] chunks = world.getLoadedChunks();
|
||||
for (final Chunk chunk : chunks) {
|
||||
final int x = chunk.getX();
|
||||
final int z = chunk.getZ();
|
||||
if (!map.containsKey(new IntegerPair(x, z))) {
|
||||
toUnload.add(chunk);
|
||||
} else if (chunk.getEntities().length > 4096) {
|
||||
for (final Entity ent : chunk.getEntities()) {
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// GC again
|
||||
System.gc();
|
||||
System.gc();
|
||||
// If still critical memory
|
||||
int free = MemUtil.calculateMemory();
|
||||
if (free <= 1) {
|
||||
for (final Chunk chunk : toUnload) {
|
||||
this.unloadChunk(chunk.getWorld().getName(), chunk);
|
||||
}
|
||||
} else if (free == Integer.MAX_VALUE) {
|
||||
for (final Chunk chunk : toUnload) {
|
||||
chunk.unload(true, false);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
toUnload = null;
|
||||
players = null;
|
||||
}
|
||||
|
||||
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
||||
return this.classChunkSectionConstructor.create(i, flag, ids);
|
||||
}
|
||||
|
||||
public char[] getIdArray(final Object obj) {
|
||||
return (char[]) this.methodGetIdArray.of(obj).call();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweChunk<Chunk> getChunk(final ChunkLoc wrap) {
|
||||
return new BukkitChunk_1_8(wrap);
|
||||
}
|
||||
|
||||
public boolean unloadChunk(final String world, final Chunk chunk) {
|
||||
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
this.mustSave.of(c).set(false);
|
||||
if (chunk.isLoaded()) {
|
||||
chunk.unload(false, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ChunkGenerator setGenerator(final World world, final ChunkGenerator newGen) {
|
||||
try {
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
final Class<? extends World> clazz = world.getClass();
|
||||
final Field generator = clazz.getDeclaredField("generator");
|
||||
generator.setAccessible(true);
|
||||
generator.set(world, newGen);
|
||||
|
||||
final Field wf = clazz.getDeclaredField("world");
|
||||
wf.setAccessible(true);
|
||||
final Object w = wf.get(world);
|
||||
final Class<?> clazz2 = w.getClass().getSuperclass();
|
||||
final Field generator2 = clazz2.getDeclaredField("generator");
|
||||
generator2.set(w, newGen);
|
||||
|
||||
return gen;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<BlockPopulator> setPopulator(final World world, final List<BlockPopulator> newPop) {
|
||||
try {
|
||||
final List<BlockPopulator> pop = world.getPopulators();
|
||||
final Field populators = world.getClass().getDeclaredField("populators");
|
||||
populators.setAccessible(true);
|
||||
populators.set(world, newPop);
|
||||
return pop;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEntitiesAndTiles(final Chunk chunk, final List<?>[] entities, final Map<?, ?> tiles) {
|
||||
try {
|
||||
final Class<? extends Chunk> clazz = chunk.getClass();
|
||||
final Method handle = clazz.getMethod("getHandle");
|
||||
final Object c = handle.invoke(chunk);
|
||||
final Class<? extends Object> clazz2 = c.getClass();
|
||||
|
||||
if (tiles.size() > 0) {
|
||||
final Field tef = clazz2.getDeclaredField("tileEntities");
|
||||
final Map<?, ?> te = (Map<?, ?>) tef.get(c);
|
||||
final Method put = te.getClass().getMethod("putAll", Map.class);
|
||||
put.invoke(te, tiles);
|
||||
}
|
||||
|
||||
final Field esf = clazz2.getDeclaredField("entitySlices");
|
||||
esf.setAccessible(true);
|
||||
esf.set(c, entities);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Object getProvider(final World world) {
|
||||
try {
|
||||
// Provider 1
|
||||
final Class<? extends World> clazz = world.getClass();
|
||||
final Field wf = clazz.getDeclaredField("world");
|
||||
wf.setAccessible(true);
|
||||
final Object w = wf.get(world);
|
||||
final Field provider = w.getClass().getSuperclass().getDeclaredField("chunkProvider");
|
||||
provider.setAccessible(true);
|
||||
// ChunkProviderServer
|
||||
final Class<? extends Object> clazz2 = w.getClass();
|
||||
final Field wpsf = clazz2.getDeclaredField("chunkProviderServer");
|
||||
// Store old provider server
|
||||
final Object worldProviderServer = wpsf.get(w);
|
||||
// Store the old provider
|
||||
final Field cp = worldProviderServer.getClass().getDeclaredField("chunkProvider");
|
||||
return cp.get(worldProviderServer);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object setProvider(final World world, Object newProvider) {
|
||||
try {
|
||||
// Provider 1
|
||||
final Class<? extends World> clazz = world.getClass();
|
||||
final Field wf = clazz.getDeclaredField("world");
|
||||
wf.setAccessible(true);
|
||||
final Object w = wf.get(world);
|
||||
// ChunkProviderServer
|
||||
final Class<? extends Object> clazz2 = w.getClass();
|
||||
final Field wpsf = clazz2.getDeclaredField("chunkProviderServer");
|
||||
// Store old provider server
|
||||
final Object worldProviderServer = wpsf.get(w);
|
||||
// Store the old provider
|
||||
final Field cp = worldProviderServer.getClass().getDeclaredField("chunkProvider");
|
||||
final Object oldProvider = cp.get(worldProviderServer);
|
||||
// Provider 2
|
||||
final Class<? extends Object> clazz3 = worldProviderServer.getClass();
|
||||
final Field provider2 = clazz3.getDeclaredField("chunkProvider");
|
||||
// If the provider needs to be calculated
|
||||
if (newProvider == null) {
|
||||
Method k;
|
||||
try {
|
||||
k = clazz2.getDeclaredMethod("k");
|
||||
} catch (final Throwable e) {
|
||||
try {
|
||||
k = clazz2.getDeclaredMethod("j");
|
||||
} catch (final Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
k.setAccessible(true);
|
||||
final Object tempProviderServer = k.invoke(w);
|
||||
newProvider = cp.get(tempProviderServer);
|
||||
// Restore old provider
|
||||
wpsf.set(w, worldProviderServer);
|
||||
}
|
||||
// Set provider for provider server
|
||||
provider2.set(worldProviderServer, newProvider);
|
||||
// Return the previous provider
|
||||
return oldProvider;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,459 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_8;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkPopulateEvent;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
|
||||
/**
|
||||
* Please ignore
|
||||
*/
|
||||
@Deprecated
|
||||
public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
||||
private boolean events;
|
||||
|
||||
private final ChunkGenerator parent;
|
||||
private final List<BlockPopulator> pops;
|
||||
private final Object provider;
|
||||
|
||||
private short[][] ids;
|
||||
private byte[][] data;
|
||||
private Map<?, ?> tiles;
|
||||
private List<?>[] entities;
|
||||
private Biome[][] biomes;
|
||||
|
||||
private final World world;
|
||||
|
||||
private final BukkitQueue_1_8 queue;
|
||||
|
||||
private void registerEvents() {
|
||||
if (this.events) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getPluginManager().registerEvents(this, Fawe.<FaweBukkit> imp());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onPopulate(final ChunkPopulateEvent event) {
|
||||
final World world = event.getWorld();
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
if (gen instanceof FaweGenerator_1_8) {
|
||||
final FaweGenerator_1_8 fawe = (FaweGenerator_1_8) gen;
|
||||
if (fawe.data == null) {
|
||||
return;
|
||||
}
|
||||
fawe.populate(event.getChunk());
|
||||
this.decouple((FaweGenerator_1_8) gen, world);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) {
|
||||
if (result[FaweCache.CACHE_I[y][x][z]] == null) {
|
||||
result[FaweCache.CACHE_I[y][x][z]] = new short[4096];
|
||||
}
|
||||
result[FaweCache.CACHE_I[y][x][z]][FaweCache.CACHE_J[y][x][z]] = blkid;
|
||||
}
|
||||
|
||||
public void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkid) {
|
||||
if (blkid.length == 1) {
|
||||
this.setBlock(result, x, y, z, blkid[0]);
|
||||
}
|
||||
final short id = blkid[FaweCache.RANDOM.random(blkid.length)];
|
||||
if (result[FaweCache.CACHE_I[y][x][z]] == null) {
|
||||
result[FaweCache.CACHE_I[y][x][z]] = new short[4096];
|
||||
}
|
||||
result[FaweCache.CACHE_I[y][x][z]][FaweCache.CACHE_J[y][x][z]] = id;
|
||||
}
|
||||
|
||||
public void setBlocks(final short[][] ids, final byte[][] data, final int x, final int z) {
|
||||
this.ids = ids;
|
||||
this.data = data == null ? new byte[16][] : data;
|
||||
if (this.parent == null) {
|
||||
this.inject(this, this.world);
|
||||
}
|
||||
this.world.regenerateChunk(x, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate chunk with the provided id / data / block count<br>
|
||||
* - You can provide null for datas / count but it will be marginally slower
|
||||
* @param ids
|
||||
* @param datas
|
||||
* @param count
|
||||
* @param chunk
|
||||
*/
|
||||
@Deprecated
|
||||
public void regenerateBlocks(final short[][] ids, byte[][] datas, short[] count, final Chunk chunk) {
|
||||
if (datas == null) {
|
||||
datas = new byte[16][];
|
||||
}
|
||||
if (count == null) {
|
||||
count = new short[16];
|
||||
}
|
||||
final int x = chunk.getX();
|
||||
final int z = chunk.getZ();
|
||||
|
||||
boolean skip = true;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (count[i] < 4096) {
|
||||
skip = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip) {
|
||||
try {
|
||||
chunk.load(true);
|
||||
this.biomes = new Biome[16][16];
|
||||
final int X = x << 4;
|
||||
final int Z = z << 4;
|
||||
for (int xx = 0; xx < 16; xx++) {
|
||||
final int xxx = X + x;
|
||||
for (int zz = 0; zz < 16; zz++) {
|
||||
final int zzz = Z + zz;
|
||||
this.biomes[xx][zz] = this.world.getBiome(xxx, zzz);
|
||||
}
|
||||
}
|
||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
final Object c = getHandele.invoke(chunk);
|
||||
final Class<? extends Object> clazz = c.getClass();
|
||||
final Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
final Field tf = clazz.getDeclaredField("tileEntities");
|
||||
final Field ef = clazz.getDeclaredField("entitySlices");
|
||||
|
||||
final Object[] sections = (Object[]) sf.get(c);
|
||||
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
final List<?>[] entities = (List<?>[]) ef.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
|
||||
// Copy entities / blockstates
|
||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Entry<?, ?> tile = iter.next();
|
||||
final Object loc = tile.getKey();
|
||||
if (xm == null) {
|
||||
final Class<? extends Object> clazz2 = loc.getClass().getSuperclass();
|
||||
xm = clazz2.getDeclaredMethod("getX");
|
||||
ym = clazz2.getDeclaredMethod("getY");
|
||||
zm = clazz2.getDeclaredMethod("getZ");
|
||||
}
|
||||
final int lx = (int) xm.invoke(loc) & 15;
|
||||
final int ly = (int) ym.invoke(loc);
|
||||
final int lz = (int) zm.invoke(loc) & 15;
|
||||
final int j = FaweCache.CACHE_I[ly][lx][lz];
|
||||
final int k = FaweCache.CACHE_J[ly][lx][lz];
|
||||
if (ids[j] == null) {
|
||||
continue;
|
||||
}
|
||||
if (ids[j][k] != 0) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
this.tiles = tiles;
|
||||
// Trim entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((entities[i] != null) && (count[i] >= 4096)) {
|
||||
entities[i].clear();
|
||||
}
|
||||
}
|
||||
this.entities = entities;
|
||||
|
||||
// Efficiently merge sections
|
||||
Method getIdArray = null;
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
if (count[j] >= 4096) {
|
||||
continue;
|
||||
}
|
||||
final Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if (getIdArray == null) {
|
||||
final Class<? extends Object> clazz2 = section.getClass();
|
||||
getIdArray = clazz2.getDeclaredMethod("getIdArray");
|
||||
}
|
||||
final char[] array = (char[]) getIdArray.invoke(section);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
final int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
short[] va = ids[j];
|
||||
if (va == null) {
|
||||
va = new short[4096];
|
||||
ids[j] = va;
|
||||
}
|
||||
final short v = va[k];
|
||||
if (v != 0) {
|
||||
continue;
|
||||
}
|
||||
final short id = FaweCache.CACHE_ID[i];
|
||||
va[k] = id;
|
||||
switch (id) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 51:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 73:
|
||||
case 74:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 122:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 169:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192:
|
||||
continue;
|
||||
case 53:
|
||||
case 67:
|
||||
case 108:
|
||||
case 109:
|
||||
case 114:
|
||||
case 128:
|
||||
case 134:
|
||||
case 135:
|
||||
case 136:
|
||||
case 156:
|
||||
case 163:
|
||||
case 164:
|
||||
case 180:
|
||||
byte db = FaweCache.CACHE_DATA[i];
|
||||
if (db == 0) {
|
||||
db = -1;
|
||||
}
|
||||
if (datas[j] == null) {
|
||||
datas[j] = new byte[4096];
|
||||
}
|
||||
datas[j][k] = db;
|
||||
continue;
|
||||
}
|
||||
final byte db = FaweCache.CACHE_DATA[i];
|
||||
if (db == 0) {
|
||||
continue;
|
||||
}
|
||||
if (datas[j] == null) {
|
||||
datas[j] = new byte[4096];
|
||||
}
|
||||
datas[j][k] = db;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Execute
|
||||
this.ids = ids;
|
||||
this.data = datas;
|
||||
if (this.parent == null) {
|
||||
this.inject(this, this.world);
|
||||
}
|
||||
this.world.regenerateChunk(x, z);
|
||||
}
|
||||
|
||||
public void inject(final FaweGenerator_1_8 gen, final World world) {
|
||||
this.queue.setGenerator(world, gen);
|
||||
this.queue.setPopulator(world, new ArrayList<BlockPopulator>());
|
||||
this.queue.setProvider(world, null);
|
||||
}
|
||||
|
||||
public void decouple(final FaweGenerator_1_8 gen, final World world) {
|
||||
gen.data = null;
|
||||
gen.ids = null;
|
||||
gen.tiles = null;
|
||||
gen.entities = null;
|
||||
gen.biomes = null;
|
||||
if (gen.parent == null) {
|
||||
this.queue.setGenerator(world, gen.parent);
|
||||
this.queue.setPopulator(world, gen.pops);
|
||||
if (gen.provider != null) {
|
||||
this.queue.setProvider(world, gen.provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FaweGenerator_1_8(final BukkitQueue_1_8 queue, final World world) {
|
||||
this.queue = queue;
|
||||
this.world = world;
|
||||
this.parent = world.getGenerator();
|
||||
this.pops = world.getPopulators();
|
||||
if (this.parent == null) {
|
||||
this.provider = queue.getProvider(world);
|
||||
} else {
|
||||
this.provider = null;
|
||||
}
|
||||
this.registerEvents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[][] generateExtBlockSections(final World world, final Random random, final int x, final int z, final BiomeGrid biomes) {
|
||||
short[][] result;
|
||||
if (this.ids != null) {
|
||||
result = this.ids;
|
||||
if ((biomes != null) && (this.biomes != null)) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
biomes.setBiome(i, j, this.biomes[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.parent != null) {
|
||||
result = this.parent.generateExtBlockSections(world, random, x, z, biomes);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void populate(final Chunk chunk) {
|
||||
for (int i = 0; i < this.data.length; i++) {
|
||||
final byte[] section = this.data[i];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < section.length; j++) {
|
||||
final byte v = section[j];
|
||||
if (v == 0) {
|
||||
continue;
|
||||
}
|
||||
final int x = FaweCache.CACHE_X[i][j];
|
||||
final int y = FaweCache.CACHE_Y[i][j];
|
||||
final int z = FaweCache.CACHE_Z[i][j];
|
||||
chunk.getBlock(x, y, z).setData(v != -1 ? v : 0, false);
|
||||
}
|
||||
}
|
||||
if ((this.tiles != null) || (this.entities != null)) {
|
||||
this.queue.setEntitiesAndTiles(chunk, this.entities, this.tiles);
|
||||
}
|
||||
final BukkitChunk_1_8 fc = new BukkitChunk_1_8(new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()));
|
||||
fc.chunk = chunk;
|
||||
this.queue.fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] generate(final World world, final Random random, final int x, final int z) {
|
||||
if (this.ids == null) {
|
||||
try {
|
||||
this.parent.generate(world, random, x, z);
|
||||
} catch (final Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[][] generateBlockSections(final World world, final Random random, final int x, final int z, final BiomeGrid biomes) {
|
||||
if ((this.ids == null) && (this.parent != null)) {
|
||||
return this.parent.generateBlockSections(world, random, x, z, biomes);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSpawn(final World world, final int x, final int z) {
|
||||
if (this.parent != null) {
|
||||
return this.parent.canSpawn(world, x, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
||||
if ((this.ids == null) && (this.parent != null)) {
|
||||
return this.parent.getDefaultPopulators(world);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getFixedSpawnLocation(final World world, final Random random) {
|
||||
if ((this.ids == null) && (this.parent != null)) {
|
||||
return this.parent.getFixedSpawnLocation(world, random);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,236 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_9;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
||||
|
||||
private int[][] ids;
|
||||
|
||||
private final short[] count;
|
||||
private final short[] air;
|
||||
private final short[] relight;
|
||||
public int[][] biomes;
|
||||
|
||||
public Chunk chunk;
|
||||
|
||||
/**
|
||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||
*/
|
||||
protected BukkitChunk_1_9(final ChunkLoc chunk) {
|
||||
super(chunk);
|
||||
this.ids = new int[16][];
|
||||
this.count = new short[16];
|
||||
this.air = new short[16];
|
||||
this.relight = new short[16];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
if (this.chunk == null) {
|
||||
final ChunkLoc cl = this.getChunkLoc();
|
||||
this.chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||
}
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkLoc(final ChunkLoc loc) {
|
||||
super.setChunkLoc(loc);
|
||||
this.chunk = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of block changes in a specified section
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getCount(final int i) {
|
||||
return this.count[i];
|
||||
}
|
||||
|
||||
public int getAir(final int i) {
|
||||
return this.air[i];
|
||||
}
|
||||
|
||||
public void setCount(final int i, final short value) {
|
||||
this.count[i] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of block changes in a specified section
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getRelight(final int i) {
|
||||
return this.relight[i];
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += this.count[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getTotalRelight() {
|
||||
if ((this.getTotalCount() == 0) && (this.biomes == null)) {
|
||||
Arrays.fill(this.count, (short) 1);
|
||||
Arrays.fill(this.relight, Short.MAX_VALUE);
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += this.relight[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw data for a section
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int[] getIdArray(final int i) {
|
||||
return this.ids[i];
|
||||
}
|
||||
|
||||
public int[][] getIdArrays() {
|
||||
return this.ids;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.ids = null;
|
||||
this.biomes = null;
|
||||
}
|
||||
|
||||
public int[][] getBiomeArray() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
||||
final int i = FaweCache.CACHE_I[y][x][z];
|
||||
final int j = FaweCache.CACHE_J[y][x][z];
|
||||
int[] vs = this.ids[i];
|
||||
if (vs == null) {
|
||||
vs = this.ids[i] = new int[4096];
|
||||
this.count[i]++;
|
||||
} else if (vs[j] == 0) {
|
||||
this.count[i]++;
|
||||
}
|
||||
switch (id) {
|
||||
case 0:
|
||||
this.air[i]++;
|
||||
vs[j] = -1;
|
||||
return;
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 51:
|
||||
case 74:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 138:
|
||||
case 169:
|
||||
this.relight[i]++;
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 73:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192:
|
||||
vs[j] = (id);
|
||||
return;
|
||||
case 130:
|
||||
case 76:
|
||||
case 62:
|
||||
this.relight[i]++;
|
||||
case 54:
|
||||
case 146:
|
||||
case 61:
|
||||
case 65:
|
||||
case 68:
|
||||
case 50:
|
||||
if (data < 2) {
|
||||
data = 2;
|
||||
}
|
||||
default:
|
||||
vs[j] = id + (data << 12);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(final int x, final int z, final BaseBiome biome) {
|
||||
if (this.biomes == null) {
|
||||
this.biomes = new int[16][];
|
||||
}
|
||||
int[] index = this.biomes[x];
|
||||
if (index == null) {
|
||||
index = this.biomes[x] = new int[16];
|
||||
}
|
||||
index[z] = biome.getId();
|
||||
}
|
||||
}
|
@ -1,624 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_9;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.IntegerPair;
|
||||
import com.boydti.fawe.object.PseudoRandom;
|
||||
import com.boydti.fawe.util.MemUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefClass;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefConstructor;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefField;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefMethod;
|
||||
import com.boydti.fawe.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
|
||||
public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
||||
|
||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||
private final RefField mustSave = this.classChunk.getField("mustSave");
|
||||
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
private final RefClass classBlock = getRefClass("{nms}.Block");
|
||||
private final RefClass classIBlockData = getRefClass("{nms}.IBlockData");
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefMethod methodInitLighting;
|
||||
private final RefConstructor classBlockPositionConstructor;
|
||||
private final RefConstructor classChunkSectionConstructor;
|
||||
private final RefMethod methodW;
|
||||
private final RefField fieldSections;
|
||||
private final RefField fieldWorld;
|
||||
private final RefMethod methodGetBlocks;
|
||||
private final RefMethod methodSetType;
|
||||
private final RefMethod methodGetByCombinedId;
|
||||
private final Object air;
|
||||
private final RefMethod methodGetWorld;
|
||||
private final RefField tileEntityListTick;
|
||||
|
||||
public BukkitQueue_1_9() throws NoSuchMethodException, RuntimeException {
|
||||
this.methodGetHandleChunk = this.classCraftChunk.getMethod("getHandle");
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.classBlockPositionConstructor = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
this.methodW = this.classWorld.getMethod("w", this.classBlockPosition.getRealClass());
|
||||
this.fieldSections = this.classChunk.getField("sections");
|
||||
this.fieldWorld = this.classChunk.getField("world");
|
||||
this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class);
|
||||
this.methodGetBlocks = this.classChunkSection.getMethod("getBlocks");
|
||||
this.methodSetType = this.classChunkSection.getMethod("setType", int.class, int.class, int.class, this.classIBlockData.getRealClass());
|
||||
this.classChunkSectionConstructor = this.classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
this.air = this.methodGetByCombinedId.call(0);
|
||||
this.tileEntityListTick = this.classWorld.getField("tileEntityListTick");
|
||||
this.methodGetWorld = this.classChunk.getMethod("getWorld");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs) {
|
||||
for (final FaweChunk<Chunk> fc : fcs) {
|
||||
sendChunk(fc);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public void sendChunk(FaweChunk<Chunk> fc) {
|
||||
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
||||
final Chunk chunk = fc.getChunk();
|
||||
final ChunkLoc loc = fc.getChunkLoc();
|
||||
chunk.getWorld().refreshChunk(loc.x, loc.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fixLighting(final FaweChunk<?> pc, final boolean fixAll) {
|
||||
try {
|
||||
final BukkitChunk_1_9 bc = (BukkitChunk_1_9) pc;
|
||||
final Chunk chunk = bc.getChunk();
|
||||
if (!chunk.isLoaded()) {
|
||||
chunk.load(false);
|
||||
}
|
||||
// Initialize lighting
|
||||
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
|
||||
this.methodInitLighting.of(c).call();
|
||||
|
||||
if (((bc.getTotalRelight() == 0) && !fixAll)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||
final Object w = this.fieldWorld.of(c).get();
|
||||
|
||||
final int X = chunk.getX() << 4;
|
||||
final int Z = chunk.getZ() << 4;
|
||||
|
||||
final RefExecutor relight = this.methodW.of(w);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
final Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if (((bc.getRelight(j) == 0) && !fixAll) || (bc.getCount(j) == 0) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0))) {
|
||||
continue;
|
||||
}
|
||||
final int[] array = bc.getIdArray(j);
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
final int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
final short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if (!fixAll) {
|
||||
continue;
|
||||
}
|
||||
if ((k & 1) == l) {
|
||||
l = 1 - l;
|
||||
continue;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 50:
|
||||
case 51:
|
||||
case 62:
|
||||
case 74:
|
||||
case 76:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
final int x = FaweCache.CACHE_X[j][k];
|
||||
final int y = FaweCache.CACHE_Y[j][k];
|
||||
final int z = FaweCache.CACHE_Z[j][k];
|
||||
if (this.isSurrounded(bc.getIdArrays(), x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
final Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
relight.call(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSurrounded(final int[][] sections, final int x, final int y, final int z) {
|
||||
return this.isSolid(this.getId(sections, x, y + 1, z))
|
||||
&& this.isSolid(this.getId(sections, x + 1, y - 1, z))
|
||||
&& this.isSolid(this.getId(sections, x - 1, y, z))
|
||||
&& this.isSolid(this.getId(sections, x, y, z + 1))
|
||||
&& this.isSolid(this.getId(sections, x, y, z - 1));
|
||||
}
|
||||
|
||||
public boolean isSolid(final int i) {
|
||||
if (i != 0) {
|
||||
final Material material = Material.getMaterial(i);
|
||||
return (material != null) && Material.getMaterial(i).isOccluding();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getId(final int[][] sections, final int x, final int y, final int z) {
|
||||
if ((x < 0) || (x > 15) || (z < 0) || (z > 15)) {
|
||||
return 1;
|
||||
}
|
||||
if ((y < 0) || (y > 255)) {
|
||||
return 1;
|
||||
}
|
||||
final int i = FaweCache.CACHE_I[y][x][z];
|
||||
final int[] section = sections[i];
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
final int j = FaweCache.CACHE_J[y][x][z];
|
||||
return section[j];
|
||||
}
|
||||
|
||||
public Object getBlocks(final Object obj) {
|
||||
return this.methodGetBlocks.of(obj).call();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setComponents(final FaweChunk<Chunk> pc) {
|
||||
final BukkitChunk_1_9 fs = (BukkitChunk_1_9) pc;
|
||||
final Chunk chunk = pc.getChunk();
|
||||
final World world = chunk.getWorld();
|
||||
chunk.load(true);
|
||||
try {
|
||||
final boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||
|
||||
// Sections
|
||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
final Object c = getHandele.invoke(chunk);
|
||||
final Object w = this.methodGetWorld.of(c).call();
|
||||
final Class<? extends Object> clazz = c.getClass();
|
||||
final Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
final Field tf = clazz.getDeclaredField("tileEntities");
|
||||
final Field ef = clazz.getDeclaredField("entitySlices");
|
||||
|
||||
final Object[] sections = (Object[]) sf.get(c);
|
||||
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
final Collection<?>[] entities = (Collection<?>[]) ef.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
|
||||
// Trim tiles
|
||||
boolean removed = false;
|
||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Entry<?, ?> tile = iter.next();
|
||||
final Object pos = tile.getKey();
|
||||
if (xm == null) {
|
||||
final Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
|
||||
xm = clazz2.getDeclaredMethod("getX");
|
||||
ym = clazz2.getDeclaredMethod("getY");
|
||||
zm = clazz2.getDeclaredMethod("getZ");
|
||||
}
|
||||
final int lx = (int) xm.invoke(pos) & 15;
|
||||
final int ly = (int) ym.invoke(pos);
|
||||
final int lz = (int) zm.invoke(pos) & 15;
|
||||
final int j = FaweCache.CACHE_I[ly][lx][lz];
|
||||
final int k = FaweCache.CACHE_J[ly][lx][lz];
|
||||
final int[] array = fs.getIdArray(j);
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
if (array[k] != 0) {
|
||||
removed = true;
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
if (removed) {
|
||||
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
||||
}
|
||||
|
||||
// Trim entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((entities[i] != null) && (fs.getCount(i) >= 4096)) {
|
||||
entities[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Efficiently merge sections
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
if (fs.getCount(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
final int[] newArray = fs.getIdArray(j);
|
||||
if (newArray == null) {
|
||||
continue;
|
||||
}
|
||||
Object section = sections[j];
|
||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||
final char[] array = new char[4096];
|
||||
for (int i = 0; i < newArray.length; i++) {
|
||||
final int combined = newArray[i];
|
||||
final int id = combined & 4095;
|
||||
final int data = combined >> 12;
|
||||
array[i] = (char) ((id << 4) + data);
|
||||
}
|
||||
section = sections[j] = this.newChunkSection(j << 4, flag, array);
|
||||
continue;
|
||||
}
|
||||
this.getBlocks(section);
|
||||
final RefExecutor setType = this.methodSetType.of(section);
|
||||
boolean fill = true;
|
||||
for (int k = 0; k < newArray.length; k++) {
|
||||
final int n = newArray[k];
|
||||
switch (n) {
|
||||
case 0:
|
||||
fill = false;
|
||||
continue;
|
||||
case -1: {
|
||||
fill = false;
|
||||
final int x = FaweCache.CACHE_X[j][k];
|
||||
final int y = FaweCache.CACHE_Y[j][k];
|
||||
final int z = FaweCache.CACHE_Z[j][k];
|
||||
setType.call(x, y & 15, z, this.air);
|
||||
continue;
|
||||
}
|
||||
default: {
|
||||
final int x = FaweCache.CACHE_X[j][k];
|
||||
final int y = FaweCache.CACHE_Y[j][k];
|
||||
final int z = FaweCache.CACHE_Z[j][k];
|
||||
final Object iblock = this.methodGetByCombinedId.call(n);
|
||||
setType.call(x, y & 15, z, iblock);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fill) {
|
||||
fs.setCount(j, Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
// Clear
|
||||
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final int[][] biomes = fs.biomes;
|
||||
final Biome[] values = Biome.values();
|
||||
if (biomes != null) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
final int[] array = biomes[x];
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
for (int z = 0; z < 16; z++) {
|
||||
final int biome = array[z];
|
||||
if (biome == 0) {
|
||||
continue;
|
||||
}
|
||||
chunk.getBlock(x, 0, z).setBiome(values[biome]);
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskManager.IMP.later(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendChunk(fs);
|
||||
}
|
||||
}, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the server is < 1% available memory (i.e. likely to crash)<br>
|
||||
* - You can disable this in the conifg<br>
|
||||
* - Will try to free up some memory<br>
|
||||
* - Clears the queue<br>
|
||||
* - Clears worldedit history<br>
|
||||
* - Clears entities<br>
|
||||
* - Unloads chunks in vacant worlds<br>
|
||||
* - Unloads non visible chunks<br>
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
// Clear the queue
|
||||
super.clear();
|
||||
ArrayDeque<Chunk> toUnload = new ArrayDeque<>();
|
||||
final int distance = Bukkit.getViewDistance() + 2;
|
||||
HashMap<String, HashMap<IntegerPair, Integer>> players = new HashMap<>();
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
// Clear history
|
||||
final FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||
final LocalSession s = fp.getSession();
|
||||
if (s != null) {
|
||||
s.clearHistory();
|
||||
s.setClipboard(null);
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final World worldObj = loc.getWorld();
|
||||
final String world = worldObj.getName();
|
||||
HashMap<IntegerPair, Integer> map = players.get(world);
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
players.put(world, map);
|
||||
}
|
||||
final IntegerPair origin = new IntegerPair(loc.getBlockX() >> 4, loc.getBlockZ() >> 4);
|
||||
Integer val = map.get(origin);
|
||||
int check;
|
||||
if (val != null) {
|
||||
if (val == distance) {
|
||||
continue;
|
||||
}
|
||||
check = distance - val;
|
||||
} else {
|
||||
check = distance;
|
||||
map.put(origin, distance);
|
||||
}
|
||||
for (int x = -distance; x <= distance; x++) {
|
||||
if ((x >= check) || (-x >= check)) {
|
||||
continue;
|
||||
}
|
||||
for (int z = -distance; z <= distance; z++) {
|
||||
if ((z >= check) || (-z >= check)) {
|
||||
continue;
|
||||
}
|
||||
final int weight = distance - Math.max(Math.abs(x), Math.abs(z));
|
||||
final IntegerPair chunk = new IntegerPair(x + origin.x, z + origin.z);
|
||||
val = map.get(chunk);
|
||||
if ((val == null) || (val < weight)) {
|
||||
map.put(chunk, weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Fawe.get().getWorldEdit().clearSessions();
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
final String name = world.getName();
|
||||
final HashMap<IntegerPair, Integer> map = players.get(name);
|
||||
if ((map == null) || (map.size() == 0)) {
|
||||
final boolean save = world.isAutoSave();
|
||||
world.setAutoSave(false);
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
this.unloadChunk(name, chunk);
|
||||
}
|
||||
world.setAutoSave(save);
|
||||
continue;
|
||||
}
|
||||
final Chunk[] chunks = world.getLoadedChunks();
|
||||
for (final Chunk chunk : chunks) {
|
||||
final int x = chunk.getX();
|
||||
final int z = chunk.getZ();
|
||||
if (!map.containsKey(new IntegerPair(x, z))) {
|
||||
toUnload.add(chunk);
|
||||
} else if (chunk.getEntities().length > 4096) {
|
||||
for (final Entity ent : chunk.getEntities()) {
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// GC again
|
||||
System.gc();
|
||||
System.gc();
|
||||
// If still critical memory
|
||||
int free = MemUtil.calculateMemory();
|
||||
if (free <= 1) {
|
||||
for (final Chunk chunk : toUnload) {
|
||||
this.unloadChunk(chunk.getWorld().getName(), chunk);
|
||||
}
|
||||
} else if (free == Integer.MAX_VALUE) {
|
||||
for (final Chunk chunk : toUnload) {
|
||||
chunk.unload(true, false);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
toUnload = null;
|
||||
players = null;
|
||||
}
|
||||
|
||||
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
||||
return this.classChunkSectionConstructor.create(i, flag, ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweChunk<Chunk> getChunk(final ChunkLoc wrap) {
|
||||
return new BukkitChunk_1_9(wrap);
|
||||
}
|
||||
|
||||
public boolean unloadChunk(final String world, final Chunk chunk) {
|
||||
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
this.mustSave.of(c).set(false);
|
||||
if (chunk.isLoaded()) {
|
||||
chunk.unload(false, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ChunkGenerator setGenerator(final World world, final ChunkGenerator newGen) {
|
||||
try {
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
final Class<? extends World> clazz = world.getClass();
|
||||
final Field generator = clazz.getDeclaredField("generator");
|
||||
generator.setAccessible(true);
|
||||
generator.set(world, newGen);
|
||||
|
||||
final Field wf = clazz.getDeclaredField("world");
|
||||
wf.setAccessible(true);
|
||||
final Object w = wf.get(world);
|
||||
final Class<?> clazz2 = w.getClass().getSuperclass();
|
||||
final Field generator2 = clazz2.getDeclaredField("generator");
|
||||
generator2.set(w, newGen);
|
||||
|
||||
return gen;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<BlockPopulator> setPopulator(final World world, final List<BlockPopulator> newPop) {
|
||||
try {
|
||||
final List<BlockPopulator> pop = world.getPopulators();
|
||||
final Field populators = world.getClass().getDeclaredField("populators");
|
||||
populators.setAccessible(true);
|
||||
populators.set(world, newPop);
|
||||
return pop;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEntitiesAndTiles(final Chunk chunk, final List<?>[] entities, final Map<?, ?> tiles) {
|
||||
try {
|
||||
final Class<? extends Chunk> clazz = chunk.getClass();
|
||||
final Method handle = clazz.getMethod("getHandle");
|
||||
final Object c = handle.invoke(chunk);
|
||||
final Class<? extends Object> clazz2 = c.getClass();
|
||||
|
||||
if (tiles.size() > 0) {
|
||||
final Field tef = clazz2.getDeclaredField("tileEntities");
|
||||
final Map<?, ?> te = (Map<?, ?>) tef.get(c);
|
||||
final Method put = te.getClass().getMethod("putAll", Map.class);
|
||||
put.invoke(te, tiles);
|
||||
}
|
||||
|
||||
final Field esf = clazz2.getDeclaredField("entitySlices");
|
||||
esf.setAccessible(true);
|
||||
esf.set(c, entities);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Object getProvider(final World world) {
|
||||
try {
|
||||
// Provider 1
|
||||
final Class<? extends World> clazz = world.getClass();
|
||||
final Field wf = clazz.getDeclaredField("world");
|
||||
wf.setAccessible(true);
|
||||
final Object w = wf.get(world);
|
||||
final Field provider = w.getClass().getSuperclass().getDeclaredField("chunkProvider");
|
||||
provider.setAccessible(true);
|
||||
// ChunkProviderServer
|
||||
final Class<? extends Object> clazz2 = w.getClass();
|
||||
final Field wpsf = clazz2.getDeclaredField("chunkProviderServer");
|
||||
// Store old provider server
|
||||
final Object worldProviderServer = wpsf.get(w);
|
||||
// Store the old provider
|
||||
final Field cp = worldProviderServer.getClass().getDeclaredField("chunkProvider");
|
||||
return cp.get(worldProviderServer);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object setProvider(final World world, Object newProvider) {
|
||||
try {
|
||||
// Provider 1
|
||||
final Class<? extends World> clazz = world.getClass();
|
||||
final Field wf = clazz.getDeclaredField("world");
|
||||
wf.setAccessible(true);
|
||||
final Object w = wf.get(world);
|
||||
// ChunkProviderServer
|
||||
final Class<? extends Object> clazz2 = w.getClass();
|
||||
final Field wpsf = clazz2.getDeclaredField("chunkProviderServer");
|
||||
// Store old provider server
|
||||
final Object worldProviderServer = wpsf.get(w);
|
||||
// Store the old provider
|
||||
final Field cp = worldProviderServer.getClass().getDeclaredField("chunkProvider");
|
||||
final Object oldProvider = cp.get(worldProviderServer);
|
||||
// Provider 2
|
||||
final Class<? extends Object> clazz3 = worldProviderServer.getClass();
|
||||
final Field provider2 = clazz3.getDeclaredField("chunkProvider");
|
||||
// If the provider needs to be calculated
|
||||
if (newProvider == null) {
|
||||
Method k;
|
||||
try {
|
||||
k = clazz2.getDeclaredMethod("k");
|
||||
} catch (final Throwable e) {
|
||||
try {
|
||||
k = clazz2.getDeclaredMethod("j");
|
||||
} catch (final Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
k.setAccessible(true);
|
||||
final Object tempProviderServer = k.invoke(w);
|
||||
newProvider = cp.get(tempProviderServer);
|
||||
// Restore old provider
|
||||
wpsf.set(w, worldProviderServer);
|
||||
}
|
||||
// Set provider for provider server
|
||||
provider2.set(worldProviderServer, newProvider);
|
||||
// Return the previous provider
|
||||
return oldProvider;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user