mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-27 10:31:36 +01:00
Cleanup some more Bukkit specific code.
This commit is contained in:
parent
ba61919168
commit
b850b5caf8
@ -17,10 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.chest;
|
||||
package com.sk89q.worldguard.chest;
|
||||
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
|
||||
/**
|
||||
@ -62,6 +63,12 @@ public interface ChestProtection {
|
||||
* @param blockType The blockType to check
|
||||
* @return Whether a type is a 'chest' (protectable block)
|
||||
*/
|
||||
boolean isChest(BlockType blockType);
|
||||
default boolean isChest(BlockType blockType) {
|
||||
return blockType == BlockTypes.CHEST
|
||||
|| blockType == BlockTypes.DISPENSER
|
||||
|| blockType == BlockTypes.FURNACE
|
||||
|| blockType == BlockTypes.TRAPPED_CHEST
|
||||
|| blockType == BlockTypes.DROPPER;
|
||||
}
|
||||
|
||||
}
|
@ -17,23 +17,21 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.chest;
|
||||
package com.sk89q.worldguard.chest;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
/**
|
||||
* Sign-based chest protection.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SignChestProtection implements ChestProtection {
|
||||
|
||||
public abstract class SignChestProtection implements ChestProtection {
|
||||
|
||||
public abstract Boolean isProtectedSign(Location block, LocalPlayer player);
|
||||
|
||||
public boolean isProtected(Location location, LocalPlayer player) {
|
||||
com.sk89q.worldedit.world.block.BlockState blockState = location.getExtent().getBlock(location.toVector());
|
||||
if (isChest(blockState.getBlockType())) {
|
||||
@ -46,68 +44,45 @@ public boolean isProtected(Location location, LocalPlayer player) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isProtectedPlacement(Location block, LocalPlayer player) {
|
||||
return isProtectedSignAround(block, player);
|
||||
}
|
||||
|
||||
|
||||
private boolean isProtectedSignAround(Location searchBlock, LocalPlayer player) {
|
||||
Location side;
|
||||
Boolean res;
|
||||
|
||||
|
||||
side = searchBlock;
|
||||
res = isProtectedSign(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
|
||||
side = searchBlock.setX(searchBlock.getX() - 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
|
||||
side = searchBlock.setX(searchBlock.getX() + 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
|
||||
side = searchBlock.setZ(searchBlock.getZ() - 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
|
||||
side = searchBlock.setZ(searchBlock.getZ() + 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Boolean isProtectedSign(Sign sign, LocalPlayer player) {
|
||||
if (sign.getLine(0).equalsIgnoreCase("[Lock]")) {
|
||||
if (player == null) { // No player, no access
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = player.getName();
|
||||
return !name.equalsIgnoreCase(sign.getLine(1).trim())
|
||||
&& !name.equalsIgnoreCase(sign.getLine(2).trim())
|
||||
&& !name.equalsIgnoreCase(sign.getLine(3).trim());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Boolean isProtectedSign(Location block, LocalPlayer player) {
|
||||
BlockState state = BukkitAdapter.adapt(block).getBlock().getState();
|
||||
if (!(state instanceof Sign)) {
|
||||
return null;
|
||||
}
|
||||
return isProtectedSign((Sign) state, player);
|
||||
}
|
||||
|
||||
|
||||
private Boolean isProtectedSignAndChest(Location block, LocalPlayer player) {
|
||||
if (!isChest(block.getExtent().getBlock(block.setY(block.getY() + 1).toVector()).getBlockType())) {
|
||||
return null;
|
||||
}
|
||||
return isProtectedSign(block, player);
|
||||
}
|
||||
|
||||
|
||||
private boolean isProtectedSignAndChestBinary(Location block, LocalPlayer player) {
|
||||
Boolean res = isProtectedSignAndChest(block, player);
|
||||
return !(res == null || !res);
|
||||
@ -116,7 +91,7 @@ private boolean isProtectedSignAndChestBinary(Location block, LocalPlayer player
|
||||
public boolean isAdjacentChestProtected(Location searchBlock, LocalPlayer player) {
|
||||
Location side;
|
||||
boolean res;
|
||||
|
||||
|
||||
side = searchBlock;
|
||||
res = isProtected(side, player);
|
||||
if (res) return res;
|
||||
@ -136,15 +111,7 @@ public boolean isAdjacentChestProtected(Location searchBlock, LocalPlayer player
|
||||
side = searchBlock.setZ(searchBlock.getZ() + 1);
|
||||
res = isProtected(side, player);
|
||||
if (res) return res;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isChest(BlockType type) {
|
||||
return type == BlockTypes.CHEST
|
||||
|| type == BlockTypes.DISPENSER
|
||||
|| type == BlockTypes.FURNACE
|
||||
|| type == BlockTypes.TRAPPED_CHEST
|
||||
|| type == BlockTypes.DROPPER;
|
||||
}
|
||||
}
|
@ -56,6 +56,9 @@ public abstract class WorldConfiguration {
|
||||
|
||||
public boolean boundedLocationFlags;
|
||||
public boolean useRegions;
|
||||
public boolean simulateSponge;
|
||||
public int spongeRadius;
|
||||
public boolean redstoneSponges;
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
|
@ -156,7 +156,7 @@ public FlagContextBuilder setObject(String key, Object value) {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected boolean tryAddToMap(String key, Object value) {
|
||||
public boolean tryAddToMap(String key, Object value) {
|
||||
if (map.containsKey(key)) return false;
|
||||
this.map.put(key, value);
|
||||
return true;
|
||||
|
@ -28,7 +28,6 @@
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -65,36 +64,6 @@ public static Player matchSinglePlayer(Server server, String name) {
|
||||
return players.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given block to fluid water.
|
||||
* Used by addSpongeWater()
|
||||
*
|
||||
* @param world
|
||||
* @param ox
|
||||
* @param oy
|
||||
* @param oz
|
||||
*/
|
||||
public static void setBlockToWater(World world, int ox, int oy, int oz) {
|
||||
Block block = world.getBlockAt(ox, oy, oz);
|
||||
if (block.getType() == Material.AIR) {
|
||||
block.setType(Material.WATER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given block is water
|
||||
*
|
||||
* @param world the world
|
||||
* @param ox x
|
||||
* @param oy y
|
||||
* @param oz z
|
||||
* @return true if it's water
|
||||
*/
|
||||
public static boolean isBlockWater(World world, int ox, int oy, int oz) {
|
||||
Block block = world.getBlockAt(ox, oy, oz);
|
||||
return block.getType() == Material.WATER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given potion is a vial of water.
|
||||
*
|
||||
|
@ -31,8 +31,8 @@
|
||||
import com.sk89q.worldguard.blacklist.logger.FileHandler;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcherParseException;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcherParser;
|
||||
import com.sk89q.worldguard.bukkit.chest.ChestProtection;
|
||||
import com.sk89q.worldguard.bukkit.chest.SignChestProtection;
|
||||
import com.sk89q.worldguard.chest.ChestProtection;
|
||||
import com.sk89q.worldguard.bukkit.chest.BukkitSignChestProtection;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandUtils;
|
||||
import com.sk89q.worldguard.bukkit.internal.TargetMatcherSet;
|
||||
import com.sk89q.worldguard.config.YamlWorldConfiguration;
|
||||
@ -67,7 +67,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
||||
|
||||
@Unreported private String worldName;
|
||||
|
||||
@Unreported private ChestProtection chestProtection = new SignChestProtection();
|
||||
@Unreported private ChestProtection chestProtection = new BukkitSignChestProtection();
|
||||
|
||||
/* Configuration data start */
|
||||
public boolean summaryOnStart;
|
||||
@ -76,13 +76,10 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
||||
public String buildPermissionDenyMessage = "";
|
||||
public boolean fireSpreadDisableToggle;
|
||||
public boolean itemDurability;
|
||||
public boolean simulateSponge;
|
||||
public int spongeRadius;
|
||||
public boolean disableExpDrops;
|
||||
public Set<PotionEffectType> blockPotions;
|
||||
public boolean blockPotionsAlways;
|
||||
public boolean pumpkinScuba;
|
||||
public boolean redstoneSponges;
|
||||
public boolean noPhysicsGravel;
|
||||
public boolean noPhysicsSand;
|
||||
public boolean ropeLadders;
|
||||
|
@ -28,7 +28,7 @@
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContextCreateEvent;
|
||||
import com.sk89q.worldguard.bukkit.protection.events.flags.FlagContextCreateEvent;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.session.SessionManager;
|
||||
|
@ -81,7 +81,7 @@
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;
|
||||
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
|
||||
import com.sk89q.worldguard.util.logging.ClassSourceValidator;
|
||||
import com.sk89q.worldguard.bukkit.util.logging.ClassSourceValidator;
|
||||
import com.sk89q.worldguard.util.logging.RecordMessagePrefixer;
|
||||
import com.sk89q.worldguard.util.task.SimpleSupervisor;
|
||||
import com.sk89q.worldguard.util.task.Supervisor;
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.chest;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.chest.SignChestProtection;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
public class BukkitSignChestProtection extends SignChestProtection {
|
||||
|
||||
private Boolean isProtectedSign(Sign sign, LocalPlayer player) {
|
||||
if (sign.getLine(0).equalsIgnoreCase("[Lock]")) {
|
||||
if (player == null) { // No player, no access
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = player.getName();
|
||||
return !name.equalsIgnoreCase(sign.getLine(1).trim())
|
||||
&& !name.equalsIgnoreCase(sign.getLine(2).trim())
|
||||
&& !name.equalsIgnoreCase(sign.getLine(3).trim());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isProtectedSign(Location block, LocalPlayer player) {
|
||||
BlockState state = BukkitAdapter.adapt(block).getBlock().getState();
|
||||
if (!(state instanceof Sign)) {
|
||||
return null;
|
||||
}
|
||||
return isProtectedSign((Sign) state, player);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.debug.*;
|
||||
import com.sk89q.worldguard.util.report.CancelReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.CancelReport;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -19,16 +19,12 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.isBlockWater;
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.setBlockToWater;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
|
||||
public final class SpongeUtil {
|
||||
|
||||
@ -38,46 +34,68 @@ private SpongeUtil() {
|
||||
/**
|
||||
* Remove water around a sponge.
|
||||
*
|
||||
* @param plugin The plugin instace
|
||||
* @param world The world the sponge isin
|
||||
* @param ox The x coordinate of the 'sponge' block
|
||||
* @param oy The y coordinate of the 'sponge' block
|
||||
* @param oz The z coordinate of the 'sponge' block
|
||||
*/
|
||||
public static void clearSpongeWater(WorldGuardPlugin plugin, World world, int ox, int oy, int oz) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
public static void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
|
||||
|
||||
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||
for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) {
|
||||
if (isBlockWater(world, ox + cx, oy + cy, oz + cz)) {
|
||||
world.getBlockAt(ox + cx, oy + cy, oz + cz).setType(Material.AIR);
|
||||
BlockVector vector = new BlockVector(ox + cx, oy + cy, oz + cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
world.setBlock(vector, BlockTypes.AIR.getDefaultState());
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given block to fluid water.
|
||||
* Used by addSpongeWater()
|
||||
*
|
||||
* @param world the world
|
||||
* @param ox x
|
||||
* @param oy y
|
||||
* @param oz z
|
||||
*/
|
||||
private static void setBlockToWater(World world, int ox, int oy, int oz) throws WorldEditException {
|
||||
BlockVector vector = new BlockVector(ox, oy, oz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.AIR) {
|
||||
world.setBlock(vector, BlockTypes.WATER.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add water around a sponge.
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
* @param world The world the sponge is located in
|
||||
* @param ox The x coordinate of the 'sponge' block
|
||||
* @param oy The y coordinate of the 'sponge' block
|
||||
* @param oz The z coordinate of the 'sponge' block
|
||||
*/
|
||||
public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox, int oy, int oz) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
|
||||
|
||||
// The negative x edge
|
||||
int cx = ox - wcfg.spongeRadius - 1;
|
||||
for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
if (isBlockWater(world, cx, cy, cz)) {
|
||||
setBlockToWater(world, cx + 1, cy, cz);
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx + 1, cy, cz);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,8 +104,13 @@ public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox,
|
||||
cx = ox + wcfg.spongeRadius + 1;
|
||||
for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
if (isBlockWater(world, cx, cy, cz)) {
|
||||
setBlockToWater(world, cx - 1, cy, cz);
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx - 1, cy, cz);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,8 +119,13 @@ public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox,
|
||||
int cy = oy - wcfg.spongeRadius - 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
if (isBlockWater(world, cx, cy, cz)) {
|
||||
setBlockToWater(world, cx, cy + 1, cz);
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy + 1, cz);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,8 +134,13 @@ public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox,
|
||||
cy = oy + wcfg.spongeRadius + 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
if (isBlockWater(world, cx, cy, cz)) {
|
||||
setBlockToWater(world, cx, cy - 1, cz);
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy - 1, cz);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,8 +149,13 @@ public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox,
|
||||
int cz = oz - wcfg.spongeRadius - 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
if (isBlockWater(world, cx, cy, cz)) {
|
||||
setBlockToWater(world, cx, cy, cz + 1);
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy, cz + 1);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,8 +164,13 @@ public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox,
|
||||
cz = oz + wcfg.spongeRadius + 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
if (isBlockWater(world, cx, cy, cz)) {
|
||||
setBlockToWater(world, cx, cy, cz - 1);
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy, cz - 1);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
int oy = target.getY();
|
||||
int oz = target.getZ();
|
||||
|
||||
SpongeUtil.clearSpongeWater(plugin, world, ox, oy, oz);
|
||||
SpongeUtil.clearSpongeWater(BukkitAdapter.adapt(world), ox, oy, oz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,10 +452,10 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
if (sponge.getType() == Material.SPONGE
|
||||
&& sponge.isBlockIndirectlyPowered()) {
|
||||
SpongeUtil.clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz);
|
||||
SpongeUtil.clearSpongeWater(BukkitAdapter.adapt(world), ox + cx, oy + cy, oz + cz);
|
||||
} else if (sponge.getType() == Material.SPONGE
|
||||
&& !sponge.isBlockIndirectlyPowered()) {
|
||||
SpongeUtil.addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz);
|
||||
SpongeUtil.addSpongeWater(BukkitAdapter.adapt(world), ox + cx, oy + cy, oz + cz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection.flags;
|
||||
package com.sk89q.worldguard.bukkit.protection.events.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext.FlagContextBuilder;
|
||||
import org.bukkit.event.Event;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.util.logging;
|
||||
package com.sk89q.worldguard.bukkit.util.logging;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
@ -17,10 +17,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.util.report;
|
||||
package com.sk89q.worldguard.bukkit.util.report;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.event.debug.CancelAttempt;
|
||||
import com.sk89q.worldguard.bukkit.util.HandlerTracer;
|
||||
import com.sk89q.worldguard.util.report.Report;
|
||||
import com.sk89q.worldguard.util.report.StackTraceReport;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.Plugin;
|
Loading…
Reference in New Issue
Block a user