mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 04:55:37 +01:00
Fixed a few more migration issues
This commit is contained in:
parent
66eb8fa553
commit
bd89bd9d2f
@ -24,7 +24,9 @@
|
|||||||
import com.sk89q.worldguard.util.report.Unreported;
|
import com.sk89q.worldguard.util.report.Unreported;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the configuration for individual worlds.
|
* Holds the configuration for individual worlds.
|
||||||
@ -68,6 +70,10 @@ public String getWorldName() {
|
|||||||
return this.worldName;
|
return this.worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> convertLegacyItems(List<String> legacyItems) {
|
||||||
|
return legacyItems.stream().map(this::convertLegacyItem).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public String convertLegacyItem(String legacy) {
|
public String convertLegacyItem(String legacy) {
|
||||||
String item = legacy;
|
String item = legacy;
|
||||||
try {
|
try {
|
||||||
@ -86,4 +92,27 @@ public String convertLegacyItem(String legacy) {
|
|||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> convertLegacyBlocks(List<String> legacyBlocks) {
|
||||||
|
return legacyBlocks.stream().map(this::convertLegacyBlock).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertLegacyBlock(String legacy) {
|
||||||
|
String block = legacy;
|
||||||
|
try {
|
||||||
|
String[] splitter = block.split(":", 2);
|
||||||
|
int id = 0;
|
||||||
|
byte data = 0;
|
||||||
|
if (splitter.length == 1) {
|
||||||
|
id = Integer.parseInt(block);
|
||||||
|
} else {
|
||||||
|
id = Integer.parseInt(splitter[0]);
|
||||||
|
data = Byte.parseByte(splitter[1]);
|
||||||
|
}
|
||||||
|
block = LegacyMapper.getInstance().getBlockFromLegacy(id, data).getBlockType().getId();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,12 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||||||
public boolean noPhysicsSand;
|
public boolean noPhysicsSand;
|
||||||
public boolean ropeLadders;
|
public boolean ropeLadders;
|
||||||
public boolean allowPortalAnywhere;
|
public boolean allowPortalAnywhere;
|
||||||
public Set<Integer> preventWaterDamage;
|
public Set<String> preventWaterDamage;
|
||||||
public boolean blockLighter;
|
public boolean blockLighter;
|
||||||
public boolean disableFireSpread;
|
public boolean disableFireSpread;
|
||||||
public Set<Integer> disableFireSpreadBlocks;
|
public Set<String> disableFireSpreadBlocks;
|
||||||
public boolean preventLavaFire;
|
public boolean preventLavaFire;
|
||||||
public Set<Integer> allowedLavaSpreadOver;
|
public Set<String> allowedLavaSpreadOver;
|
||||||
public boolean blockTNTExplosions;
|
public boolean blockTNTExplosions;
|
||||||
public boolean blockTNTBlockDamage;
|
public boolean blockTNTBlockDamage;
|
||||||
public boolean blockCreeperExplosions;
|
public boolean blockCreeperExplosions;
|
||||||
@ -142,7 +142,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||||||
public boolean disableCreatureCropTrampling;
|
public boolean disableCreatureCropTrampling;
|
||||||
public boolean disablePlayerCropTrampling;
|
public boolean disablePlayerCropTrampling;
|
||||||
public boolean preventLightningFire;
|
public boolean preventLightningFire;
|
||||||
public Set<Integer> disallowedLightningBlocks;
|
public Set<String> disallowedLightningBlocks;
|
||||||
public boolean disableThunder;
|
public boolean disableThunder;
|
||||||
public boolean disableWeather;
|
public boolean disableWeather;
|
||||||
public boolean alwaysRaining;
|
public boolean alwaysRaining;
|
||||||
@ -162,7 +162,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||||||
public boolean disableEndermanGriefing;
|
public boolean disableEndermanGriefing;
|
||||||
public boolean disableSnowmanTrails;
|
public boolean disableSnowmanTrails;
|
||||||
public boolean disableSoilDehydration;
|
public boolean disableSoilDehydration;
|
||||||
public Set<Integer> allowedSnowFallOver;
|
public Set<String> allowedSnowFallOver;
|
||||||
public boolean regionInvinciblityRemovesMobs;
|
public boolean regionInvinciblityRemovesMobs;
|
||||||
public boolean regionNetherPortalProtection;
|
public boolean regionNetherPortalProtection;
|
||||||
public boolean fakePlayerBuildOverride;
|
public boolean fakePlayerBuildOverride;
|
||||||
@ -279,7 +279,7 @@ public void loadConfiguration() {
|
|||||||
noPhysicsSand = getBoolean("physics.no-physics-sand", false);
|
noPhysicsSand = getBoolean("physics.no-physics-sand", false);
|
||||||
ropeLadders = getBoolean("physics.vine-like-rope-ladders", false);
|
ropeLadders = getBoolean("physics.vine-like-rope-ladders", false);
|
||||||
allowPortalAnywhere = getBoolean("physics.allow-portal-anywhere", false);
|
allowPortalAnywhere = getBoolean("physics.allow-portal-anywhere", false);
|
||||||
preventWaterDamage = new HashSet<>(getIntList("physics.disable-water-damage-blocks", null));
|
preventWaterDamage = new HashSet<>(convertLegacyBlocks(getStringList("physics.disable-water-damage-blocks", null)));
|
||||||
|
|
||||||
blockTNTExplosions = getBoolean("ignition.block-tnt", false);
|
blockTNTExplosions = getBoolean("ignition.block-tnt", false);
|
||||||
blockTNTBlockDamage = getBoolean("ignition.block-tnt-block-damage", false);
|
blockTNTBlockDamage = getBoolean("ignition.block-tnt-block-damage", false);
|
||||||
@ -287,8 +287,8 @@ public void loadConfiguration() {
|
|||||||
|
|
||||||
preventLavaFire = getBoolean("fire.disable-lava-fire-spread", true);
|
preventLavaFire = getBoolean("fire.disable-lava-fire-spread", true);
|
||||||
disableFireSpread = getBoolean("fire.disable-all-fire-spread", false);
|
disableFireSpread = getBoolean("fire.disable-all-fire-spread", false);
|
||||||
disableFireSpreadBlocks = new HashSet<>(getIntList("fire.disable-fire-spread-blocks", null));
|
disableFireSpreadBlocks = new HashSet<>(convertLegacyBlocks(getStringList("fire.disable-fire-spread-blocks", null)));
|
||||||
allowedLavaSpreadOver = new HashSet<>(getIntList("fire.lava-spread-blocks", null));
|
allowedLavaSpreadOver = new HashSet<>(convertLegacyBlocks(getStringList("fire.lava-spread-blocks", null)));
|
||||||
|
|
||||||
blockCreeperExplosions = getBoolean("mobs.block-creeper-explosions", false);
|
blockCreeperExplosions = getBoolean("mobs.block-creeper-explosions", false);
|
||||||
blockCreeperBlockDamage = getBoolean("mobs.block-creeper-block-damage", false);
|
blockCreeperBlockDamage = getBoolean("mobs.block-creeper-block-damage", false);
|
||||||
@ -332,7 +332,7 @@ public void loadConfiguration() {
|
|||||||
disableCreatureCropTrampling = getBoolean("crops.disable-creature-trampling", false);
|
disableCreatureCropTrampling = getBoolean("crops.disable-creature-trampling", false);
|
||||||
disablePlayerCropTrampling = getBoolean("crops.disable-player-trampling", false);
|
disablePlayerCropTrampling = getBoolean("crops.disable-player-trampling", false);
|
||||||
|
|
||||||
disallowedLightningBlocks = new HashSet<>(getIntList("weather.prevent-lightning-strike-blocks", null));
|
disallowedLightningBlocks = new HashSet<>(convertLegacyBlocks(getStringList("weather.prevent-lightning-strike-blocks", null)));
|
||||||
preventLightningFire = getBoolean("weather.disable-lightning-strike-fire", false);
|
preventLightningFire = getBoolean("weather.disable-lightning-strike-fire", false);
|
||||||
disableThunder = getBoolean("weather.disable-thunderstorm", false);
|
disableThunder = getBoolean("weather.disable-thunderstorm", false);
|
||||||
disableWeather = getBoolean("weather.disable-weather", false);
|
disableWeather = getBoolean("weather.disable-weather", false);
|
||||||
@ -351,7 +351,7 @@ public void loadConfiguration() {
|
|||||||
disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
|
disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
|
||||||
disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
|
disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
|
||||||
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
|
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
|
||||||
allowedSnowFallOver = new HashSet<>(getIntList("dynamics.snow-fall-blocks", null));
|
allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
|
||||||
|
|
||||||
useRegions = getBoolean("regions.enable", true);
|
useRegions = getBoolean("regions.enable", true);
|
||||||
regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
|
regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
|
||||||
|
@ -72,15 +72,14 @@
|
|||||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardWeatherListener;
|
import com.sk89q.worldguard.bukkit.listener.WorldGuardWeatherListener;
|
||||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardWorldListener;
|
import com.sk89q.worldguard.bukkit.listener.WorldGuardWorldListener;
|
||||||
import com.sk89q.worldguard.bukkit.listener.WorldRulesListener;
|
import com.sk89q.worldguard.bukkit.listener.WorldRulesListener;
|
||||||
|
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||||
import com.sk89q.worldguard.bukkit.util.Events;
|
import com.sk89q.worldguard.bukkit.util.Events;
|
||||||
import com.sk89q.worldguard.protection.GlobalRegionManager;
|
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||||
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;
|
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;
|
||||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
|
||||||
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
|
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
|
||||||
import com.sk89q.worldguard.util.logging.ClassSourceValidator;
|
import com.sk89q.worldguard.util.logging.ClassSourceValidator;
|
||||||
import com.sk89q.worldguard.util.logging.RecordMessagePrefixer;
|
import com.sk89q.worldguard.util.logging.RecordMessagePrefixer;
|
||||||
@ -128,7 +127,6 @@ public class WorldGuardPlugin extends JavaPlugin {
|
|||||||
private static WorldGuardPlugin inst;
|
private static WorldGuardPlugin inst;
|
||||||
private static BukkitWorldGuardPlatform platform;
|
private static BukkitWorldGuardPlatform platform;
|
||||||
private final CommandsManager<CommandSender> commands;
|
private final CommandsManager<CommandSender> commands;
|
||||||
private GlobalRegionManager globalRegionManager;
|
|
||||||
private final Supervisor supervisor = new SimpleSupervisor();
|
private final Supervisor supervisor = new SimpleSupervisor();
|
||||||
private ListeningExecutorService executorService;
|
private ListeningExecutorService executorService;
|
||||||
private ProfileService profileService;
|
private ProfileService profileService;
|
||||||
@ -189,7 +187,6 @@ public void onEnable() {
|
|||||||
WorldGuard.getInstance().setPlatform(platform = new BukkitWorldGuardPlatform()); // Initialise WorldGuard
|
WorldGuard.getInstance().setPlatform(platform = new BukkitWorldGuardPlatform()); // Initialise WorldGuard
|
||||||
WorldGuard.getInstance().setup();
|
WorldGuard.getInstance().setup();
|
||||||
BukkitSessionManager sessionManager = (BukkitSessionManager) platform.getSessionManager();
|
BukkitSessionManager sessionManager = (BukkitSessionManager) platform.getSessionManager();
|
||||||
globalRegionManager = new GlobalRegionManager(WorldGuard.getInstance().getPlatform().getRegionContainer());
|
|
||||||
|
|
||||||
// Set the proper command injector
|
// Set the proper command injector
|
||||||
commands.setInjector(new SimpleInjector(this));
|
commands.setInjector(new SimpleInjector(this));
|
||||||
@ -338,17 +335,6 @@ public String convertThrowable(@Nullable Throwable throwable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the GlobalRegionManager.
|
|
||||||
*
|
|
||||||
* @return the plugin's global region manager
|
|
||||||
* @deprecated use #getRegionContainer()
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public GlobalRegionManager getGlobalRegionManager() {
|
|
||||||
return globalRegionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the supervisor.
|
* Get the supervisor.
|
||||||
*
|
*
|
||||||
|
@ -19,10 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.listener;
|
package com.sk89q.worldguard.bukkit.listener;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
@ -176,7 +173,7 @@ public void onBlockFromTo(BlockFromToEvent event) {
|
|||||||
Material targetId = blockTo.getType();
|
Material targetId = blockTo.getType();
|
||||||
|
|
||||||
if ((isAir || isWater) &&
|
if ((isAir || isWater) &&
|
||||||
wcfg.preventWaterDamage.contains(targetId)) {
|
wcfg.preventWaterDamage.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -185,7 +182,7 @@ public void onBlockFromTo(BlockFromToEvent event) {
|
|||||||
if (wcfg.allowedLavaSpreadOver.size() > 0 && isLava) {
|
if (wcfg.allowedLavaSpreadOver.size() > 0 && isLava) {
|
||||||
Material targetId = blockTo.getRelative(0, -1, 0).getType();
|
Material targetId = blockTo.getRelative(0, -1, 0).getType();
|
||||||
|
|
||||||
if (!wcfg.allowedLavaSpreadOver.contains(targetId)) {
|
if (!wcfg.allowedLavaSpreadOver.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -261,11 +258,11 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
int y = block.getY();
|
int y = block.getY();
|
||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
|
|
||||||
if (wcfg.disableFireSpreadBlocks.contains(world.getBlockAt(x, y - 1, z).getType())
|
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y - 1, z).getType()).getId())
|
||||||
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockAt(x + 1, y, z).getType())
|
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x + 1, y, z).getType()).getId())
|
||||||
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockAt(x - 1, y, z).getType())
|
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x - 1, y, z).getType()).getId())
|
||||||
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockAt(x, y, z - 1).getType())
|
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z - 1).getType()).getId())
|
||||||
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockAt(x, y, z + 1).getType())) {
|
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z + 1).getType()).getId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -330,7 +327,7 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
if (wcfg.disableFireSpreadBlocks.size() > 0) {
|
if (wcfg.disableFireSpreadBlocks.size() > 0) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
if (wcfg.disableFireSpreadBlocks.contains(block.getType())) {
|
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(block.getType()).getId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);
|
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);
|
||||||
return;
|
return;
|
||||||
@ -520,8 +517,8 @@ public void onBlockForm(BlockFormEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.ICE_FORM, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.ICE_FORM))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -535,13 +532,13 @@ public void onBlockForm(BlockFormEvent event) {
|
|||||||
if (wcfg.allowedSnowFallOver.size() > 0) {
|
if (wcfg.allowedSnowFallOver.size() > 0) {
|
||||||
Material targetId = event.getBlock().getRelative(0, -1, 0).getType();
|
Material targetId = event.getBlock().getRelative(0, -1, 0).getType();
|
||||||
|
|
||||||
if (!wcfg.allowedSnowFallOver.contains(targetId)) {
|
if (!wcfg.allowedSnowFallOver.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.SNOW_FALL, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SNOW_FALL))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -568,8 +565,8 @@ public void onBlockSpread(BlockSpreadEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.MUSHROOMS, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.MUSHROOMS))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -580,8 +577,8 @@ public void onBlockSpread(BlockSpreadEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.GRASS_SPREAD, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.GRASS_SPREAD))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -593,9 +590,8 @@ public void onBlockSpread(BlockSpreadEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.useRegions
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
&& !plugin.getGlobalRegionManager().allows(
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.MYCELIUM_SPREAD))) {
|
||||||
Flags.MYCELIUM_SPREAD, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -607,9 +603,8 @@ public void onBlockSpread(BlockSpreadEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.useRegions
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
&& !plugin.getGlobalRegionManager().allows(
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.VINE_GROWTH))) {
|
||||||
Flags.VINE_GROWTH, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -630,8 +625,8 @@ public void onBlockFade(BlockFadeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.ICE_MELT, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.ICE_MELT))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -641,8 +636,8 @@ public void onBlockFade(BlockFadeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.SNOW_MELT, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SNOW_MELT))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -651,8 +646,8 @@ public void onBlockFade(BlockFadeEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
Flags.SOIL_DRY, BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SOIL_DRY))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,8 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
if (type == DamageCause.BLOCK_EXPLOSION
|
if (type == DamageCause.BLOCK_EXPLOSION
|
||||||
&& (wcfg.disableExplosionDamage || wcfg.blockOtherExplosions
|
&& (wcfg.disableExplosionDamage || wcfg.blockOtherExplosions
|
||||||
|| (wcfg.explosionFlagCancellation
|
|| (wcfg.explosionFlagCancellation
|
||||||
&& !plugin.getGlobalRegionManager().allows(Flags.OTHER_EXPLOSION, localPlayer.getLocation())))) {
|
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
|
.queryState(localPlayer.getLocation(), (RegionAssociable) null, Flags.OTHER_EXPLOSION))))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -179,9 +180,11 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
if (type == DamageCause.BLOCK_EXPLOSION
|
if (type == DamageCause.BLOCK_EXPLOSION
|
||||||
&& (wcfg.blockOtherExplosions
|
&& (wcfg.blockOtherExplosions
|
||||||
|| (wcfg.explosionFlagCancellation
|
|| (wcfg.explosionFlagCancellation
|
||||||
&& !plugin.getGlobalRegionManager().allows(Flags.OTHER_EXPLOSION, BukkitAdapter.adapt(defender.getLocation()))))) {
|
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||||
|
.queryState(BukkitAdapter.adapt(defender.getLocation()), (RegionAssociable) null, Flags.OTHER_EXPLOSION))))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -94,17 +95,14 @@ public void onLightningStrike(LightningStrikeEvent event) {
|
|||||||
|
|
||||||
if (wcfg.disallowedLightningBlocks.size() > 0) {
|
if (wcfg.disallowedLightningBlocks.size() > 0) {
|
||||||
Material targetId = event.getLightning().getLocation().getBlock().getType();
|
Material targetId = event.getLightning().getLocation().getBlock().getType();
|
||||||
if (wcfg.disallowedLightningBlocks.contains(targetId)) {
|
if (wcfg.disallowedLightningBlocks.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Location loc = event.getLightning().getLocation();
|
Location loc = event.getLightning().getLocation();
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
ApplicableRegionSet set =
|
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(loc), (RegionAssociable) null, Flags.LIGHTNING))) {
|
||||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(loc));
|
|
||||||
|
|
||||||
if (!set.allows(Flags.LIGHTNING)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.protection;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
|
||||||
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
|
||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the legacy class for accessing region data.
|
|
||||||
*
|
|
||||||
* @deprecated use {@link WorldGuardPlatform#getRegionContainer()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class GlobalRegionManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new instance.
|
|
||||||
*
|
|
||||||
* @param container the container
|
|
||||||
*/
|
|
||||||
public GlobalRegionManager(RegionContainer container) {
|
|
||||||
checkNotNull(container);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the value of a state flag at a location.
|
|
||||||
*
|
|
||||||
* @param flag the flag
|
|
||||||
* @param location the location
|
|
||||||
* @return true if set to true
|
|
||||||
* @deprecated use {@link RegionContainer#createQuery()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean allows(StateFlag flag, Location location) {
|
|
||||||
return StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(location, (RegionAssociable) null, flag));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user