mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-28 08:06:45 +01:00
Merge branch 'v5' into v6
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java # Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java # Core/src/main/java/com/plotsquared/core/command/Deny.java # Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java
This commit is contained in:
commit
e8e116312a
@ -195,18 +195,26 @@ public class BlockEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||
switch (event.getChangedType()) {
|
||||
case COMPARATOR: {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.adapt(block.getLocation());
|
||||
if (location.isPlotArea()) {
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlotAbs();
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getChangedType().hasGravity() && plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
sendBlockChange(event.getBlock().getLocation(), event.getBlock().getBlockData());
|
||||
plot.debug("Prevented block physics and resent block change because disable-physics = true");
|
||||
return;
|
||||
}
|
||||
switch (event.getChangedType()) {
|
||||
case COMPARATOR: {
|
||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
plot.debug("Prevented comparator update because redstone = false");
|
||||
@ -220,16 +228,6 @@ public class BlockEventListener implements Listener {
|
||||
case TURTLE_EGG:
|
||||
case TURTLE_HELMET:
|
||||
case TURTLE_SPAWN_EGG: {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.adapt(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
plot.debug("Prevented block physics because disable-physics = true");
|
||||
@ -238,20 +236,10 @@ public class BlockEventListener implements Listener {
|
||||
}
|
||||
default:
|
||||
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
||||
Block block = event.getBlock();
|
||||
switch (block.getType()) {
|
||||
case PISTON:
|
||||
case STICKY_PISTON:
|
||||
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
||||
Location location = BukkitUtil.adapt(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
switch (piston.getFacing()) {
|
||||
case EAST:
|
||||
location = location.add(1, 0, 0);
|
||||
|
@ -203,7 +203,12 @@ public class EntityEventListener implements Listener {
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
if (plot != null) {
|
||||
if (block.getType().hasGravity()) {
|
||||
BlockEventListener.sendBlockChange(block.getLocation(), block.getBlockData());
|
||||
}
|
||||
plot.debug("Falling block event was cancelled because disable-physics = true");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getTo().hasGravity()) {
|
||||
|
@ -162,14 +162,15 @@ public abstract class SchematicHandler {
|
||||
try (OutputStream output = con.getOutputStream();
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) {
|
||||
String CRLF = "\r\n";
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("--").append(boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF);
|
||||
writer.append("Content-Type: text/plain; charset=" + StandardCharsets.UTF_8.displayName()).append(CRLF);
|
||||
writer.append("Content-Type: text/plain; charset=").append(StandardCharsets.UTF_8.displayName()).append(CRLF);
|
||||
String param = "value";
|
||||
writer.append(CRLF).append(param).append(CRLF).flush();
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + '"').append(CRLF);
|
||||
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF);
|
||||
writer.append("--").append(boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"").append(filename)
|
||||
.append(String.valueOf('"')).append(CRLF);
|
||||
writer.append("Content-Type: ").append(URLConnection.guessContentTypeFromName(filename)).append(CRLF);
|
||||
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
|
||||
writer.append(CRLF).flush();
|
||||
writeTask.value = new AbstractDelegateOutputStream(output) {
|
||||
@ -179,7 +180,7 @@ public abstract class SchematicHandler {
|
||||
writeTask.run();
|
||||
output.flush();
|
||||
writer.append(CRLF).flush();
|
||||
writer.append("--" + boundary + "--").append(CRLF).flush();
|
||||
writer.append("--").append(boundary).append("--").append(CRLF).flush();
|
||||
}
|
||||
String content;
|
||||
try (Scanner scanner = new Scanner(con.getInputStream()).useDelimiter("\\A")) {
|
||||
@ -323,16 +324,9 @@ public abstract class SchematicHandler {
|
||||
|
||||
final Location pos1 = Location
|
||||
.at(plot.getWorldName(), region.getMinimumPoint().getX() + xOffset, y_offset_actual, region.getMinimumPoint().getZ() + zOffset);
|
||||
final Location pos2 = pos1.add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
// Paste schematic here
|
||||
final QueueCoordinator queue = plot.getArea().getQueue();
|
||||
|
||||
@ -547,7 +541,7 @@ public abstract class SchematicHandler {
|
||||
|
||||
schematic.put("Palette", new CompoundTag(paletteTag));
|
||||
schematic.put("BlockData", new ByteArrayTag(buffer.toByteArray()));
|
||||
schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));
|
||||
schematic.put("BlockEntities", new ListTag(CompoundTag.class, tileEntities));
|
||||
|
||||
schematic.put("BiomePaletteMax", new IntTag(biomePalette.size()));
|
||||
|
||||
@ -671,8 +665,6 @@ public abstract class SchematicHandler {
|
||||
for (Map.Entry<String, Tag> entry : block.getNbtData().getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
// Remove 'id' if it exists. We want 'Id'
|
||||
values.remove("id");
|
||||
|
||||
// Positions are kept in NBT, we don't want that.
|
||||
values.remove("x");
|
||||
@ -680,6 +672,11 @@ public abstract class SchematicHandler {
|
||||
values.remove("z");
|
||||
|
||||
values.put("Id", new StringTag(block.getNbtId()));
|
||||
|
||||
// Remove 'id' if it exists. We want 'Id'.
|
||||
// Do this after we get "getNbtId" cos otherwise "getNbtId" doesn't work.
|
||||
// Dum.
|
||||
values.remove("id");
|
||||
values.put("Pos", new IntArrayTag(new int[] {relativeX, relativeY, relativeZ}));
|
||||
|
||||
tileEntities.add(new CompoundTag(values));
|
||||
|
@ -29,6 +29,7 @@ is to provide a lag-free and smooth experience.
|
||||
* [Discord](https://discord.gg/KxkjDVg)
|
||||
* [Wiki](https://wiki.intellectualsites.com/plotsquared/home)
|
||||
* [Issues](https://issues.intellectualsites.com/projects/ps)
|
||||
* [Translations](https://intellectualsites.crowdin.com/plotsquared/)
|
||||
|
||||
### Developer Resources
|
||||
* [API Documentation](https://wiki.intellectualsites.com/en/plotsquared/developer/development-portal)
|
||||
|
Loading…
Reference in New Issue
Block a user