mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 02:55:23 +01:00
It compiles.
This commit is contained in:
parent
89db0d9fee
commit
2e8d14c995
@ -22,6 +22,7 @@
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||
|
||||
@ -40,7 +41,7 @@ public static WorldGuard getInstance() {
|
||||
}
|
||||
|
||||
public WorldGuard() {
|
||||
flagRegistry.setInitialized(true);
|
||||
Flags.registerAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.config;
|
||||
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.util.report.Unreported;
|
||||
|
||||
@ -66,4 +67,23 @@ public Blacklist getBlacklist() {
|
||||
public String getWorldName() {
|
||||
return this.worldName;
|
||||
}
|
||||
|
||||
public String convertLegacyItem(String legacy) {
|
||||
String item = legacy;
|
||||
try {
|
||||
String[] splitter = item.split(":", 2);
|
||||
int id = 0;
|
||||
byte data = 0;
|
||||
if (splitter.length == 1) {
|
||||
id = Integer.parseInt(item);
|
||||
} else {
|
||||
id = Integer.parseInt(splitter[0]);
|
||||
data = Byte.parseByte(splitter[1]);
|
||||
}
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.protection;
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import com.sk89q.worldguard.domains.Association;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
@ -40,115 +40,115 @@ public final class Flags {
|
||||
public static final StateFlag PASSTHROUGH = register(new StateFlag("passthrough", false));
|
||||
|
||||
// This flag is unlike the others. It forces the checking of region membership
|
||||
public static final StateFlag BUILD = new BuildFlag("build", true);
|
||||
public static final StateFlag BUILD = register(new BuildFlag("build", true));
|
||||
|
||||
// These flags are used in tandem with the BUILD flag - if the player can
|
||||
// build, then the following flags do not need to be checked (although they
|
||||
// are still checked for DENY), so they are false by default
|
||||
public static final StateFlag BLOCK_BREAK = new StateFlag("block-break", false);
|
||||
public static final StateFlag BLOCK_PLACE = new StateFlag("block-place", false);
|
||||
public static final StateFlag USE = new StateFlag("use", false);
|
||||
public static final StateFlag INTERACT = new StateFlag("interact", false);
|
||||
public static final StateFlag DAMAGE_ANIMALS = new StateFlag("damage-animals", false);
|
||||
public static final StateFlag PVP = new StateFlag("pvp", false);
|
||||
public static final StateFlag SLEEP = new StateFlag("sleep", false);
|
||||
public static final StateFlag TNT = new StateFlag("tnt", false);
|
||||
public static final StateFlag CHEST_ACCESS = new StateFlag("chest-access", false);
|
||||
public static final StateFlag PLACE_VEHICLE = new StateFlag("vehicle-place", false);
|
||||
public static final StateFlag DESTROY_VEHICLE = new StateFlag("vehicle-destroy", false);
|
||||
public static final StateFlag LIGHTER = new StateFlag("lighter", false);
|
||||
public static final StateFlag RIDE = new StateFlag("ride", false);
|
||||
public static final StateFlag POTION_SPLASH = new StateFlag("potion-splash", false);
|
||||
public static final StateFlag BLOCK_BREAK = register(new StateFlag("block-break", false));
|
||||
public static final StateFlag BLOCK_PLACE = register(new StateFlag("block-place", false));
|
||||
public static final StateFlag USE = register(new StateFlag("use", false));
|
||||
public static final StateFlag INTERACT = register(new StateFlag("interact", false));
|
||||
public static final StateFlag DAMAGE_ANIMALS = register(new StateFlag("damage-animals", false));
|
||||
public static final StateFlag PVP = register(new StateFlag("pvp", false));
|
||||
public static final StateFlag SLEEP = register(new StateFlag("sleep", false));
|
||||
public static final StateFlag TNT = register(new StateFlag("tnt", false));
|
||||
public static final StateFlag CHEST_ACCESS = register(new StateFlag("chest-access", false));
|
||||
public static final StateFlag PLACE_VEHICLE = register(new StateFlag("vehicle-place", false));
|
||||
public static final StateFlag DESTROY_VEHICLE = register(new StateFlag("vehicle-destroy", false));
|
||||
public static final StateFlag LIGHTER = register(new StateFlag("lighter", false));
|
||||
public static final StateFlag RIDE = register(new StateFlag("ride", false));
|
||||
public static final StateFlag POTION_SPLASH = register(new StateFlag("potion-splash", false));
|
||||
|
||||
// These flags are similar to the ones above (used in tandem with BUILD),
|
||||
// but their defaults are set to TRUE because it is more user friendly.
|
||||
// However, it is not possible to disable these flags by default in all
|
||||
// regions because setting DENY in __global__ would also override the
|
||||
// BUILD flag. In the future, StateFlags will need a DISALLOW state.
|
||||
public static final StateFlag ITEM_PICKUP = new StateFlag("item-pickup", true); // Intentionally true
|
||||
public static final StateFlag ITEM_DROP = new StateFlag("item-drop", true); // Intentionally true
|
||||
public static final StateFlag EXP_DROPS = new StateFlag("exp-drops", true); // Intentionally true
|
||||
public static final StateFlag ITEM_PICKUP = register(new StateFlag("item-pickup", true)); // Intentionally true
|
||||
public static final StateFlag ITEM_DROP = register(new StateFlag("item-drop", true)); // Intentionally true
|
||||
public static final StateFlag EXP_DROPS = register(new StateFlag("exp-drops", true)); // Intentionally true
|
||||
|
||||
// These flags adjust behavior and are not checked in tandem with the
|
||||
// BUILD flag so they need to be TRUE for their defaults.
|
||||
public static final StateFlag MOB_DAMAGE = new StateFlag("mob-damage", true);
|
||||
public static final StateFlag MOB_SPAWNING = new StateFlag("mob-spawning", true);
|
||||
public static final StateFlag CREEPER_EXPLOSION = new StateFlag("creeper-explosion", true);
|
||||
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = new StateFlag("enderdragon-block-damage", true);
|
||||
public static final StateFlag GHAST_FIREBALL = new StateFlag("ghast-fireball", true);
|
||||
public static final StateFlag FIREWORK_DAMAGE = new StateFlag("firework-damage", true);
|
||||
public static final StateFlag OTHER_EXPLOSION = new StateFlag("other-explosion", true);
|
||||
public static final StateFlag WITHER_DAMAGE = new StateFlag("wither-damage", true);
|
||||
public static final StateFlag FIRE_SPREAD = new StateFlag("fire-spread", true);
|
||||
public static final StateFlag LAVA_FIRE = new StateFlag("lava-fire", true);
|
||||
public static final StateFlag LIGHTNING = new StateFlag("lightning", true);
|
||||
public static final StateFlag WATER_FLOW = new StateFlag("water-flow", true);
|
||||
public static final StateFlag LAVA_FLOW = new StateFlag("lava-flow", true);
|
||||
public static final StateFlag PISTONS = new StateFlag("pistons", true);
|
||||
public static final StateFlag SNOW_FALL = new StateFlag("snow-fall", true);
|
||||
public static final StateFlag SNOW_MELT = new StateFlag("snow-melt", true);
|
||||
public static final StateFlag ICE_FORM = new StateFlag("ice-form", true);
|
||||
public static final StateFlag ICE_MELT = new StateFlag("ice-melt", true);
|
||||
public static final StateFlag MUSHROOMS = new StateFlag("mushroom-growth", true);
|
||||
public static final StateFlag LEAF_DECAY = new StateFlag("leaf-decay", true);
|
||||
public static final StateFlag GRASS_SPREAD = new StateFlag("grass-growth", true);
|
||||
public static final StateFlag MYCELIUM_SPREAD = new StateFlag("mycelium-spread", true);
|
||||
public static final StateFlag VINE_GROWTH = new StateFlag("vine-growth", true);
|
||||
public static final StateFlag SOIL_DRY = new StateFlag("soil-dry", true);
|
||||
public static final StateFlag ENDER_BUILD = new StateFlag("enderman-grief", true);
|
||||
public static final StateFlag INVINCIBILITY = new StateFlag("invincible", false);
|
||||
public static final StateFlag SEND_CHAT = new StateFlag("send-chat", true);
|
||||
public static final StateFlag RECEIVE_CHAT = new StateFlag("receive-chat", true);
|
||||
public static final StateFlag ENTRY = new StateFlag("entry", true, RegionGroup.NON_MEMBERS);
|
||||
public static final StateFlag EXIT = new StateFlag("exit", true, RegionGroup.NON_MEMBERS);
|
||||
public static final StateFlag ENDERPEARL = new StateFlag("enderpearl", true);
|
||||
public static final StateFlag CHORUS_TELEPORT = new StateFlag("chorus-fruit-teleport", true);
|
||||
public static final StateFlag ENTITY_PAINTING_DESTROY = new StateFlag("entity-painting-destroy", true);
|
||||
public static final StateFlag ENTITY_ITEM_FRAME_DESTROY = new StateFlag("entity-item-frame-destroy", true);
|
||||
public static final StateFlag FALL_DAMAGE = new StateFlag("fall-damage", true);
|
||||
public static final StateFlag MOB_DAMAGE = register(new StateFlag("mob-damage", true));
|
||||
public static final StateFlag MOB_SPAWNING = register(new StateFlag("mob-spawning", true));
|
||||
public static final StateFlag CREEPER_EXPLOSION = register(new StateFlag("creeper-explosion", true));
|
||||
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = register(new StateFlag("enderdragon-block-damage", true));
|
||||
public static final StateFlag GHAST_FIREBALL = register(new StateFlag("ghast-fireball", true));
|
||||
public static final StateFlag FIREWORK_DAMAGE = register(new StateFlag("firework-damage", true));
|
||||
public static final StateFlag OTHER_EXPLOSION = register(new StateFlag("other-explosion", true));
|
||||
public static final StateFlag WITHER_DAMAGE = register(new StateFlag("wither-damage", true));
|
||||
public static final StateFlag FIRE_SPREAD = register(new StateFlag("fire-spread", true));
|
||||
public static final StateFlag LAVA_FIRE = register(new StateFlag("lava-fire", true));
|
||||
public static final StateFlag LIGHTNING = register(new StateFlag("lightning", true));
|
||||
public static final StateFlag WATER_FLOW = register(new StateFlag("water-flow", true));
|
||||
public static final StateFlag LAVA_FLOW = register(new StateFlag("lava-flow", true));
|
||||
public static final StateFlag PISTONS = register(new StateFlag("pistons", true));
|
||||
public static final StateFlag SNOW_FALL = register(new StateFlag("snow-fall", true));
|
||||
public static final StateFlag SNOW_MELT = register(new StateFlag("snow-melt", true));
|
||||
public static final StateFlag ICE_FORM = register(new StateFlag("ice-form", true));
|
||||
public static final StateFlag ICE_MELT = register(new StateFlag("ice-melt", true));
|
||||
public static final StateFlag MUSHROOMS = register(new StateFlag("mushroom-growth", true));
|
||||
public static final StateFlag LEAF_DECAY = register(new StateFlag("leaf-decay", true));
|
||||
public static final StateFlag GRASS_SPREAD = register(new StateFlag("grass-growth", true));
|
||||
public static final StateFlag MYCELIUM_SPREAD = register(new StateFlag("mycelium-spread", true));
|
||||
public static final StateFlag VINE_GROWTH = register(new StateFlag("vine-growth", true));
|
||||
public static final StateFlag SOIL_DRY = register(new StateFlag("soil-dry", true));
|
||||
public static final StateFlag ENDER_BUILD = register(new StateFlag("enderman-grief", true));
|
||||
public static final StateFlag INVINCIBILITY = register(new StateFlag("invincible", false));
|
||||
public static final StateFlag SEND_CHAT = register(new StateFlag("send-chat", true));
|
||||
public static final StateFlag RECEIVE_CHAT = register(new StateFlag("receive-chat", true));
|
||||
public static final StateFlag ENTRY = register(new StateFlag("entry", true, RegionGroup.NON_MEMBERS));
|
||||
public static final StateFlag EXIT = register(new StateFlag("exit", true, RegionGroup.NON_MEMBERS));
|
||||
public static final StateFlag ENDERPEARL = register(new StateFlag("enderpearl", true));
|
||||
public static final StateFlag CHORUS_TELEPORT = register(new StateFlag("chorus-fruit-teleport", true));
|
||||
public static final StateFlag ENTITY_PAINTING_DESTROY = register(new StateFlag("entity-painting-destroy", true));
|
||||
public static final StateFlag ENTITY_ITEM_FRAME_DESTROY = register(new StateFlag("entity-item-frame-destroy", true));
|
||||
public static final StateFlag FALL_DAMAGE = register(new StateFlag("fall-damage", true));
|
||||
|
||||
// FlagUtil that adjust behaviors that aren't state flags
|
||||
public static final StringFlag DENY_MESSAGE = new StringFlag("deny-message",
|
||||
public static final StringFlag DENY_MESSAGE = register(new StringFlag("deny-message",
|
||||
ColorCodeBuilder.asColorCodes(new StyledFragment().append(new StyledFragment(Style.RED, Style.BOLD).append("Hey!"))
|
||||
.append(new StyledFragment(Style.GRAY).append(" Sorry, but you can't %what% here."))));
|
||||
public static final StringFlag ENTRY_DENY_MESSAGE = new StringFlag("entry-deny-message",
|
||||
.append(new StyledFragment(Style.GRAY).append(" Sorry, but you can't %what% here.")))));
|
||||
public static final StringFlag ENTRY_DENY_MESSAGE = register(new StringFlag("entry-deny-message",
|
||||
ColorCodeBuilder.asColorCodes(new StyledFragment().append(new StyledFragment(Style.RED, Style.BOLD).append("Hey!"))
|
||||
.append(new StyledFragment(Style.GRAY).append(" You are not permitted to enter this area."))));
|
||||
public static final StringFlag EXIT_DENY_MESSAGE = new StringFlag("exit-deny-message",
|
||||
.append(new StyledFragment(Style.GRAY).append(" You are not permitted to enter this area.")))));
|
||||
public static final StringFlag EXIT_DENY_MESSAGE = register(new StringFlag("exit-deny-message",
|
||||
ColorCodeBuilder.asColorCodes(new StyledFragment().append(new StyledFragment(Style.RED, Style.BOLD).append("Hey!"))
|
||||
.append(new StyledFragment(Style.GRAY).append(" You are not permitted to leave this area."))));
|
||||
public static final BooleanFlag EXIT_OVERRIDE = new BooleanFlag("exit-override");
|
||||
public static final StateFlag EXIT_VIA_TELEPORT = new StateFlag("exit-via-teleport", true);
|
||||
public static final StringFlag GREET_MESSAGE = new StringFlag("greeting");
|
||||
public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell");
|
||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
||||
public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave");
|
||||
public static final SetFlag<EntityType> DENY_SPAWN = new SetFlag<>("deny-spawn", new EntityTypeFlag(null));
|
||||
public static final Flag<GameMode> GAME_MODE = new GameModeTypeFlag("game-mode");
|
||||
public static final StringFlag TIME_LOCK = new StringFlag("time-lock");
|
||||
public static final Flag<WeatherType> WEATHER_LOCK = new WeatherTypeFlag("weather-lock");
|
||||
public static final IntegerFlag HEAL_DELAY = new IntegerFlag("heal-delay");
|
||||
public static final IntegerFlag HEAL_AMOUNT = new IntegerFlag("heal-amount");
|
||||
public static final DoubleFlag MIN_HEAL = new DoubleFlag("heal-min-health");
|
||||
public static final DoubleFlag MAX_HEAL = new DoubleFlag("heal-max-health");
|
||||
public static final IntegerFlag FEED_DELAY = new IntegerFlag("feed-delay");
|
||||
public static final IntegerFlag FEED_AMOUNT = new IntegerFlag("feed-amount");
|
||||
public static final IntegerFlag MIN_FOOD = new IntegerFlag("feed-min-hunger");
|
||||
public static final IntegerFlag MAX_FOOD = new IntegerFlag("feed-max-hunger");
|
||||
// public static final IntegerFlag MAX_PLAYERS = new IntegerFlag("max-players-allowed");
|
||||
// public static final StringFlag MAX_PLAYERS_MESSAGE = new StringFlag("max-players-reject-message");
|
||||
public static final LocationFlag TELE_LOC = new LocationFlag("teleport", RegionGroup.MEMBERS);
|
||||
public static final LocationFlag SPAWN_LOC = new LocationFlag("spawn", RegionGroup.MEMBERS);
|
||||
.append(new StyledFragment(Style.GRAY).append(" You are not permitted to leave this area.")))));
|
||||
public static final BooleanFlag EXIT_OVERRIDE = register(new BooleanFlag("exit-override"));
|
||||
public static final StateFlag EXIT_VIA_TELEPORT = register(new StateFlag("exit-via-teleport", true));
|
||||
public static final StringFlag GREET_MESSAGE = register(new StringFlag("greeting"));
|
||||
public static final StringFlag FAREWELL_MESSAGE = register(new StringFlag("farewell"));
|
||||
public static final BooleanFlag NOTIFY_ENTER = register(new BooleanFlag("notify-enter"));
|
||||
public static final BooleanFlag NOTIFY_LEAVE = register(new BooleanFlag("notify-leave"));
|
||||
public static final SetFlag<EntityType> DENY_SPAWN = register(new SetFlag<>("deny-spawn", new EntityTypeFlag(null)));
|
||||
public static final Flag<GameMode> GAME_MODE = register(new GameModeTypeFlag("game-mode"));
|
||||
public static final StringFlag TIME_LOCK = register(new StringFlag("time-lock"));
|
||||
public static final Flag<WeatherType> WEATHER_LOCK = register(new WeatherTypeFlag("weather-lock"));
|
||||
public static final IntegerFlag HEAL_DELAY = register(new IntegerFlag("heal-delay"));
|
||||
public static final IntegerFlag HEAL_AMOUNT = register(new IntegerFlag("heal-amount"));
|
||||
public static final DoubleFlag MIN_HEAL = register(new DoubleFlag("heal-min-health"));
|
||||
public static final DoubleFlag MAX_HEAL = register(new DoubleFlag("heal-max-health"));
|
||||
public static final IntegerFlag FEED_DELAY = register(new IntegerFlag("feed-delay"));
|
||||
public static final IntegerFlag FEED_AMOUNT = register(new IntegerFlag("feed-amount"));
|
||||
public static final IntegerFlag MIN_FOOD = register(new IntegerFlag("feed-min-hunger"));
|
||||
public static final IntegerFlag MAX_FOOD = register(new IntegerFlag("feed-max-hunger"));
|
||||
// public static final IntegerFlag MAX_PLAYERS = register(new IntegerFlag("max-players-allowed"));
|
||||
// public static final StringFlag MAX_PLAYERS_MESSAGE = register(new StringFlag("max-players-reject-message"));
|
||||
public static final LocationFlag TELE_LOC = register(new LocationFlag("teleport", RegionGroup.MEMBERS));
|
||||
public static final LocationFlag SPAWN_LOC = register(new LocationFlag("spawn", RegionGroup.MEMBERS));
|
||||
public static final SetFlag<String> BLOCKED_CMDS = register(new SetFlag<>("blocked-cmds", new CommandStringFlag(null)));
|
||||
public static final SetFlag<String> ALLOWED_CMDS = register(new SetFlag<>("allowed-cmds", new CommandStringFlag(null)));
|
||||
|
||||
// these 3 are not used by worldguard and should be re-implemented in plugins that may use them using custom flag api
|
||||
@Deprecated
|
||||
public static final StateFlag ENABLE_SHOP = new StateFlag("allow-shop", false);
|
||||
public static final StateFlag ENABLE_SHOP = register(new StateFlag("allow-shop", false));
|
||||
@Deprecated
|
||||
public static final BooleanFlag BUYABLE = new BooleanFlag("buyable");
|
||||
public static final BooleanFlag BUYABLE = register(new BooleanFlag("buyable"));
|
||||
@Deprecated
|
||||
public static final DoubleFlag PRICE = new DoubleFlag("price");
|
||||
public static final DoubleFlag PRICE = register(new DoubleFlag("price"));
|
||||
|
||||
private Flags() {
|
||||
}
|
||||
@ -179,4 +179,5 @@ public static Flag<?> fuzzyMatchFlag(FlagRegistry flagRegistry, String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerAll() {}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -65,6 +66,13 @@ public interface FlagRegistry extends Iterable<Flag<?>> {
|
||||
@Nullable
|
||||
Flag<?> get(String name);
|
||||
|
||||
/**
|
||||
* Get all flags
|
||||
*
|
||||
* @return All flags
|
||||
*/
|
||||
List<Flag<?>> getAll();
|
||||
|
||||
/**
|
||||
* Unmarshal a raw map of values into a map of flags with their
|
||||
* unmarshalled values.
|
||||
|
@ -21,12 +21,14 @@
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@ -41,7 +43,7 @@ public class SimpleFlagRegistry implements FlagRegistry {
|
||||
|
||||
private final Object lock = new Object();
|
||||
private final ConcurrentMap<String, Flag<?>> flags = Maps.newConcurrentMap();
|
||||
private boolean initialized;
|
||||
private boolean initialized = false;
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
@ -98,6 +100,11 @@ public Flag<?> get(String name) {
|
||||
return flags.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Flag<?>> getAll() {
|
||||
return Lists.newArrayList(this.flags.values());
|
||||
}
|
||||
|
||||
private Flag<?> getOrCreate(String name) {
|
||||
Flag<?> flag = get(name);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public Session(SessionManager manager) {
|
||||
*
|
||||
* @param handler A new handler
|
||||
*/
|
||||
void register(Handler handler) {
|
||||
public void register(Handler handler) {
|
||||
handlers.put(handler.getClass(), handler);
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public <T extends Handler> T getHandler(Class<T> type) {
|
||||
*
|
||||
* @param player The player
|
||||
*/
|
||||
void initialize(LocalPlayer player) {
|
||||
public void initialize(LocalPlayer player) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
Location location = player.getLocation();
|
||||
ApplicableRegionSet set = query.getApplicableRegions(location);
|
||||
@ -113,7 +113,7 @@ void initialize(LocalPlayer player) {
|
||||
*
|
||||
* @param player The player
|
||||
*/
|
||||
void tick(LocalPlayer player) {
|
||||
public void tick(LocalPlayer player) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
Location location = player.getLocation();
|
||||
ApplicableRegionSet set = query.getApplicableRegions(location);
|
||||
@ -128,7 +128,7 @@ void tick(LocalPlayer player) {
|
||||
*
|
||||
* @param player The player
|
||||
*/
|
||||
void resetState(LocalPlayer player) {
|
||||
public void resetState(LocalPlayer player) {
|
||||
initialize(player);
|
||||
needRefresh.set(true);
|
||||
}
|
||||
|
@ -22,12 +22,12 @@
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
|
||||
class WorldPlayerTuple {
|
||||
public class WorldPlayerTuple {
|
||||
|
||||
final World world;
|
||||
final LocalPlayer player;
|
||||
private final World world;
|
||||
private final LocalPlayer player;
|
||||
|
||||
WorldPlayerTuple(World world, LocalPlayer player) {
|
||||
public WorldPlayerTuple(World world, LocalPlayer player) {
|
||||
this.world = world;
|
||||
this.player = player;
|
||||
}
|
||||
@ -45,6 +45,14 @@ public boolean equals(Object o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public LocalPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = world.hashCode();
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
@ -208,6 +208,6 @@ public static Target createTarget(ItemStack item) {
|
||||
*/
|
||||
public static Target createTarget(Material material) {
|
||||
checkNotNull(material);
|
||||
return new ItemTarget(BukkitAdapter.adapt(material));
|
||||
return new ItemTarget(BukkitAdapter.asItemType(material));
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.blacklist.BlacklistLoggerHandler;
|
||||
@ -127,7 +128,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
||||
public boolean disableMobDamage;
|
||||
public boolean highFreqFlags;
|
||||
public boolean checkLiquidFlow;
|
||||
public int regionWand;
|
||||
public String regionWand;
|
||||
public Set<EntityType> blockCreatureSpawn;
|
||||
public boolean allowTamedSpawns;
|
||||
// public boolean useiConomy;
|
||||
@ -361,7 +362,7 @@ public void loadConfiguration() {
|
||||
explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
|
||||
highFreqFlags = getBoolean("regions.high-frequency-flags", false);
|
||||
checkLiquidFlow = getBoolean("regions.protect-against-liquid-flow", false);
|
||||
regionWand = getInt("regions.wand", 334);
|
||||
regionWand = convertLegacyItem(getString("regions.wand", ItemTypes.LEATHER.getId()));
|
||||
maxClaimVolume = getInt("regions.max-claim-volume", 30000);
|
||||
claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false);
|
||||
boundedLocationFlags = getBoolean("regions.location-flags-only-inside-regions", false);
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
@ -11,7 +30,7 @@
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContextCreateEvent;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.session.SessionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -73,11 +73,12 @@
|
||||
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.registry.SimpleFlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;
|
||||
import com.sk89q.worldguard.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
|
||||
import com.sk89q.worldguard.util.logging.ClassSourceValidator;
|
||||
import com.sk89q.worldguard.util.logging.RecordMessagePrefixer;
|
||||
@ -255,6 +256,8 @@ public void run() {
|
||||
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
|
||||
Events.fire(event);
|
||||
}
|
||||
|
||||
((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).setInitialized(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.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.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
@ -52,26 +52,26 @@ public boolean isProtectedPlacement(Location block, LocalPlayer player) {
|
||||
}
|
||||
|
||||
private boolean isProtectedSignAround(Location searchBlock, LocalPlayer player) {
|
||||
Block side;
|
||||
Location side;
|
||||
Boolean res;
|
||||
|
||||
side = searchBlock;
|
||||
res = isProtectedSign(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(-1, 0, 0);
|
||||
side = searchBlock.setX(searchBlock.getX() - 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(1, 0, 0);
|
||||
side = searchBlock.setX(searchBlock.getX() + 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, -1);
|
||||
side = searchBlock.setZ(searchBlock.getZ() - 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, 1);
|
||||
side = searchBlock.setZ(searchBlock.getZ() + 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
@ -94,7 +94,7 @@ private Boolean isProtectedSign(Sign sign, LocalPlayer player) {
|
||||
}
|
||||
|
||||
private Boolean isProtectedSign(Location block, LocalPlayer player) {
|
||||
BlockState state = block.getState();
|
||||
BlockState state = BukkitAdapter.adapt(block).getBlock().getState();
|
||||
if (!(state instanceof Sign)) {
|
||||
return null;
|
||||
}
|
||||
@ -102,7 +102,7 @@ private Boolean isProtectedSign(Location block, LocalPlayer player) {
|
||||
}
|
||||
|
||||
private Boolean isProtectedSignAndChest(Location block, LocalPlayer player) {
|
||||
if (!isChest(block.getRelative(0, 1, 0).getTypeId())) {
|
||||
if (!isChest(player.getExtent().getBlock(block.setY(block.getY() + 1).toVector()).getBlockType())) {
|
||||
return null;
|
||||
}
|
||||
return isProtectedSign(block, player);
|
||||
@ -114,28 +114,28 @@ private boolean isProtectedSignAndChestBinary(Location block, LocalPlayer player
|
||||
}
|
||||
|
||||
public boolean isAdjacentChestProtected(Location searchBlock, LocalPlayer player) {
|
||||
Block side;
|
||||
Boolean res;
|
||||
Location side;
|
||||
boolean res;
|
||||
|
||||
side = searchBlock;
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(-1, 0, 0);
|
||||
if (res) return res;
|
||||
|
||||
side = searchBlock.setX(searchBlock.getX() - 1);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(1, 0, 0);
|
||||
if (res) return res;
|
||||
|
||||
side = searchBlock.setX(searchBlock.getX() + 1);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, -1);
|
||||
if (res) return res;
|
||||
|
||||
side = searchBlock.setZ(searchBlock.getZ() - 1);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, 1);
|
||||
if (res) return res;
|
||||
|
||||
side = searchBlock.setZ(searchBlock.getZ() + 1);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res) return res;
|
||||
if (res) return res;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -23,11 +23,10 @@
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.GodMode;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -65,9 +64,10 @@ public void god(CommandContext args, CommandSender sender) throws CommandExcepti
|
||||
}
|
||||
|
||||
for (Player player : targets) {
|
||||
Session session = plugin.getSessionManager().get(player);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
|
||||
|
||||
if (GodMode.set(player, session, true)) {
|
||||
if (GodMode.set(localPlayer, session, true)) {
|
||||
player.setFireTicks(0);
|
||||
|
||||
// Tell the user
|
||||
@ -284,8 +284,7 @@ public void stack(CommandContext args, CommandSender sender) throws CommandExcep
|
||||
// Same type?
|
||||
// Blocks store their color in the damage value
|
||||
if (item2.getType() == item.getType() &&
|
||||
((!ItemType.usesDamageValue(item.getTypeId()) && ignoreDamaged)
|
||||
|| item.getDurability() == item2.getDurability()) &&
|
||||
(ignoreDamaged || item.getDurability() == item2.getDurability()) &&
|
||||
((item.getItemMeta() == null && item2.getItemMeta() == null)
|
||||
|| (item.getItemMeta() != null &&
|
||||
item.getItemMeta().equals(item2.getItemMeta())))) {
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
@ -54,7 +56,8 @@ public void stopFire(CommandContext args, CommandSender sender) throws CommandEx
|
||||
world = plugin.matchWorld(sender, args.getString(0));
|
||||
}
|
||||
|
||||
BukkitWorldConfiguration wcfg = plugin.getGlobalStateManager().get(world);
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (!wcfg.fireSpreadDisableToggle) {
|
||||
plugin.getServer().broadcastMessage(
|
||||
@ -83,7 +86,8 @@ public void allowFire(CommandContext args, CommandSender sender) throws CommandE
|
||||
world = plugin.matchWorld(sender, args.getString(0));
|
||||
}
|
||||
|
||||
BukkitWorldConfiguration wcfg = plugin.getGlobalStateManager().get(world);
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
plugin.getServer().broadcastMessage(ChatColor.YELLOW
|
||||
@ -102,7 +106,7 @@ public void allowFire(CommandContext args, CommandSender sender) throws CommandE
|
||||
@CommandPermissions({"worldguard.halt-activity"})
|
||||
public void stopLag(CommandContext args, CommandSender sender) throws CommandException {
|
||||
|
||||
ConfigurationManager configManager = plugin.getGlobalStateManager();
|
||||
ConfigurationManager configManager = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
|
||||
if (args.hasFlag('i')) {
|
||||
if (configManager.activityHaltToggle) {
|
||||
|
@ -25,7 +25,10 @@
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.AsyncCommandHelper;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
@ -56,13 +59,13 @@ public void addMember(CommandContext args, CommandSender sender) throws CommandE
|
||||
|
||||
World world = checkWorld(args, sender, 'w'); // Get the world
|
||||
String id = args.getString(0);
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion region = checkExistingRegion(manager, id, true);
|
||||
|
||||
id = region.getId();
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayAddMembers(region)) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayAddMembers(region)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -92,6 +95,7 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
|
||||
warnAboutSaveFailures(sender);
|
||||
|
||||
World world = checkWorld(args, sender, 'w'); // Get the world
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
|
||||
|
||||
Player player = null;
|
||||
LocalPlayer localPlayer = null;
|
||||
@ -102,7 +106,7 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, weWorld);
|
||||
ProtectedRegion region = checkExistingRegion(manager, id, true);
|
||||
|
||||
id = region.getId();
|
||||
@ -114,7 +118,7 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
|
||||
if (flag != null && flag && owners != null && owners.size() == 0) {
|
||||
// TODO: Move this to an event
|
||||
if (!plugin.hasPermission(player, "worldguard.region.unlimited")) {
|
||||
int maxRegionCount = plugin.getGlobalStateManager().get(world).getMaxRegionCount(player);
|
||||
int maxRegionCount = ((BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(weWorld)).getMaxRegionCount(player);
|
||||
if (maxRegionCount >= 0 && manager.getRegionCountOfPlayer(localPlayer)
|
||||
>= maxRegionCount) {
|
||||
throw new CommandException("You already own the maximum allowed amount of regions.");
|
||||
@ -123,7 +127,7 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.unclaimed." + id.toLowerCase());
|
||||
} else {
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayAddOwners(region)) {
|
||||
if (!getPermissionModel(localPlayer).mayAddOwners(region)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
}
|
||||
@ -156,11 +160,11 @@ public void removeMember(CommandContext args, CommandSender sender) throws Comma
|
||||
|
||||
World world = checkWorld(args, sender, 'w'); // Get the world
|
||||
String id = args.getString(0);
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion region = checkExistingRegion(manager, id, true);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayRemoveMembers(region)) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayRemoveMembers(region)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -203,11 +207,11 @@ public void removeOwner(CommandContext args, CommandSender sender) throws Comman
|
||||
|
||||
World world = checkWorld(args, sender, 'w'); // Get the world
|
||||
String id = args.getString(0);
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion region = checkExistingRegion(manager, id, true);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayRemoveOwners(region)) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayRemoveOwners(region)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,10 @@
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.BukkitRegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
@ -106,15 +108,16 @@ public RegionCommands(WorldGuardPlugin plugin) {
|
||||
public void define(CommandContext args, CommandSender sender) throws CommandException {
|
||||
warnAboutSaveFailures(sender);
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayDefine()) {
|
||||
if (!getPermissionModel(localPlayer).mayDefine()) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
String id = checkRegionId(args.getString(0), false);
|
||||
|
||||
RegionManager manager = checkRegionManager(plugin, player.getWorld());
|
||||
RegionManager manager = checkRegionManager(plugin, localPlayer.getWorld());
|
||||
|
||||
checkRegionDoesNotExist(manager, id, true);
|
||||
|
||||
@ -124,7 +127,7 @@ public void define(CommandContext args, CommandSender sender) throws CommandExce
|
||||
region = new GlobalProtectedRegion(id);
|
||||
} else {
|
||||
region = checkRegionFromSelection(player, id);
|
||||
warnAboutDimensions(player, region);
|
||||
warnAboutDimensions(localPlayer, region);
|
||||
informNewUser(player, manager, region);
|
||||
}
|
||||
|
||||
@ -157,16 +160,17 @@ public void redefine(CommandContext args, CommandSender sender) throws CommandEx
|
||||
warnAboutSaveFailures(sender);
|
||||
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
World world = player.getWorld();
|
||||
|
||||
String id = checkRegionId(args.getString(0), false);
|
||||
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, localPlayer.getWorld());
|
||||
|
||||
ProtectedRegion existing = checkExistingRegion(manager, id, false);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayRedefine(existing)) {
|
||||
if (!getPermissionModel(localPlayer).mayRedefine(existing)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -176,7 +180,7 @@ public void redefine(CommandContext args, CommandSender sender) throws CommandEx
|
||||
region = new GlobalProtectedRegion(id);
|
||||
} else {
|
||||
region = checkRegionFromSelection(player, id);
|
||||
warnAboutDimensions(player, region);
|
||||
warnAboutDimensions(localPlayer, region);
|
||||
informNewUser(player, manager, region);
|
||||
}
|
||||
|
||||
@ -213,7 +217,7 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
|
||||
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
RegionPermissionModel permModel = getPermissionModel(sender);
|
||||
RegionPermissionModel permModel = getPermissionModel(localPlayer);
|
||||
|
||||
// Check permissions
|
||||
if (!permModel.mayClaim()) {
|
||||
@ -222,12 +226,13 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
|
||||
|
||||
String id = checkRegionId(args.getString(0), false);
|
||||
|
||||
RegionManager manager = checkRegionManager(plugin, player.getWorld());
|
||||
RegionManager manager = checkRegionManager(plugin, localPlayer.getWorld());
|
||||
|
||||
checkRegionDoesNotExist(manager, id, false);
|
||||
ProtectedRegion region = checkRegionFromSelection(player, id);
|
||||
|
||||
BukkitWorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||
|
||||
// Check whether the player has created too many regions
|
||||
if (!permModel.mayClaimRegionsUnbounded()) {
|
||||
@ -310,19 +315,19 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
|
||||
min = 0, max = 1)
|
||||
public void select(CommandContext args, CommandSender sender) throws CommandException {
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
World world = player.getWorld();
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
RegionManager manager = checkRegionManager(plugin, localPlayer.getWorld());
|
||||
ProtectedRegion existing;
|
||||
|
||||
// If no arguments were given, get the region that the player is inside
|
||||
if (args.argsLength() == 0) {
|
||||
existing = checkRegionStandingIn(manager, player);
|
||||
existing = checkRegionStandingIn(manager, localPlayer);
|
||||
} else {
|
||||
existing = checkExistingRegion(manager, args.getString(0), false);
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).maySelect(existing)) {
|
||||
if (!getPermissionModel(localPlayer).maySelect(existing)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -346,10 +351,11 @@ public void info(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
warnAboutSaveFailures(sender);
|
||||
|
||||
World world = checkWorld(args, sender, 'w'); // Get the world
|
||||
RegionPermissionModel permModel = getPermissionModel(sender);
|
||||
Actor actor = plugin.getWorldEdit().wrapCommandSender(sender);
|
||||
RegionPermissionModel permModel = getPermissionModel(actor);
|
||||
|
||||
// Lookup the existing region
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion existing;
|
||||
|
||||
if (args.argsLength() == 0) { // Get region from where the player is
|
||||
@ -358,7 +364,7 @@ public void info(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
"the region with /region info -w world_name region_name.");
|
||||
}
|
||||
|
||||
existing = checkRegionStandingIn(manager, (Player) sender, true);
|
||||
existing = checkRegionStandingIn(manager, plugin.wrapPlayer((Player) sender), true);
|
||||
} else { // Get region from the ID
|
||||
existing = checkExistingRegion(manager, args.getString(0), true);
|
||||
}
|
||||
@ -412,6 +418,7 @@ public void list(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
|
||||
World world = checkWorld(args, sender, 'w'); // Get the world
|
||||
String ownedBy;
|
||||
Actor actor = plugin.getWorldEdit().wrapCommandSender(sender);
|
||||
|
||||
// Get page
|
||||
int page = args.getInteger(0, 1) - 1;
|
||||
@ -427,14 +434,14 @@ public void list(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayList(ownedBy)) {
|
||||
if (!getPermissionModel(actor).mayList(ownedBy)) {
|
||||
ownedBy = sender.getName(); // assume they only want their own
|
||||
if (!getPermissionModel(sender).mayList(ownedBy)) {
|
||||
if (!getPermissionModel(actor).mayList(ownedBy)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
}
|
||||
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
|
||||
RegionLister task = new RegionLister(plugin, manager, sender);
|
||||
task.setPage(page);
|
||||
@ -469,8 +476,9 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
String flagName = args.getString(1);
|
||||
String value = args.argsLength() >= 3 ? args.getJoinedStrings(2) : null;
|
||||
RegionGroup groupValue = null;
|
||||
FlagRegistry flagRegistry = plugin.getFlagRegistry();
|
||||
RegionPermissionModel permModel = getPermissionModel(sender);
|
||||
FlagRegistry flagRegistry = WorldGuard.getInstance().getFlagRegistry();
|
||||
Actor actor = plugin.getWorldEdit().wrapCommandSender(sender);
|
||||
RegionPermissionModel permModel = getPermissionModel(actor);
|
||||
|
||||
if (args.hasFlag('e')) {
|
||||
if (value != null) {
|
||||
@ -486,7 +494,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
}
|
||||
|
||||
// Lookup the existing region
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion existing = checkExistingRegion(manager, args.getString(0), true);
|
||||
|
||||
// Check permissions
|
||||
@ -556,7 +564,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
// Parse the [-g group] separately so entire command can abort if parsing
|
||||
// the [value] part throws an error.
|
||||
try {
|
||||
groupValue = groupFlag.parseInput(FlagContext.create().setSender(sender).setInput(group).setObject("region", existing).build());
|
||||
groupValue = groupFlag.parseInput(FlagContext.create().setSender(actor).setInput(group).setObject("region", existing).build());
|
||||
} catch (InvalidFlagFormat e) {
|
||||
throw new CommandException(e.getMessage());
|
||||
}
|
||||
@ -567,7 +575,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
if (value != null) {
|
||||
// Set the flag if [value] was given even if [-g group] was given as well
|
||||
try {
|
||||
setFlag(existing, foundFlag, sender, value);
|
||||
setFlag(existing, foundFlag, actor, value);
|
||||
} catch (InvalidFlagFormat e) {
|
||||
throw new CommandException(e.getMessage());
|
||||
}
|
||||
@ -637,11 +645,11 @@ public void setPriority(CommandContext args, CommandSender sender) throws Comman
|
||||
int priority = args.getInteger(1);
|
||||
|
||||
// Lookup the existing region
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion existing = checkExistingRegion(manager, args.getString(0), false);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).maySetPriority(existing)) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).maySetPriority(existing)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -672,7 +680,7 @@ public void setParent(CommandContext args, CommandSender sender) throws CommandE
|
||||
ProtectedRegion child;
|
||||
|
||||
// Lookup the existing region
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
|
||||
// Get parent and child
|
||||
child = checkExistingRegion(manager, args.getString(0), false);
|
||||
@ -683,7 +691,7 @@ public void setParent(CommandContext args, CommandSender sender) throws CommandE
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).maySetParent(child, parent)) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).maySetParent(child, parent)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -739,11 +747,11 @@ public void remove(CommandContext args, CommandSender sender) throws CommandExce
|
||||
boolean unsetParent = args.hasFlag('u');
|
||||
|
||||
// Lookup the existing region
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
ProtectedRegion existing = checkExistingRegion(manager, args.getString(0), true);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayDelete(existing)) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayDelete(existing)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -788,12 +796,12 @@ public void load(CommandContext args, final CommandSender sender) throws Command
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayForceLoadRegions()) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayForceLoadRegions()) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
if (world != null) {
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
|
||||
if (manager == null) {
|
||||
throw new CommandException("No region manager exists for world '" + world.getName() + "'.");
|
||||
@ -805,10 +813,10 @@ public void load(CommandContext args, final CommandSender sender) throws Command
|
||||
.forRegionDataLoad(world, false);
|
||||
} else {
|
||||
// Load regions for all worlds
|
||||
List<RegionManager> managers = new ArrayList<RegionManager>();
|
||||
List<RegionManager> managers = new ArrayList<>();
|
||||
|
||||
for (World w : Bukkit.getServer().getWorlds()) {
|
||||
RegionManager manager = plugin.getRegionContainer().get(w);
|
||||
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(w));
|
||||
if (manager != null) {
|
||||
managers.add(manager);
|
||||
}
|
||||
@ -847,12 +855,12 @@ public void save(CommandContext args, final CommandSender sender) throws Command
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayForceSaveRegions()) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayForceSaveRegions()) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
if (world != null) {
|
||||
RegionManager manager = checkRegionManager(plugin, world);
|
||||
RegionManager manager = checkRegionManager(plugin, BukkitAdapter.adapt(world));
|
||||
|
||||
if (manager == null) {
|
||||
throw new CommandException("No region manager exists for world '" + world.getName() + "'.");
|
||||
@ -864,10 +872,10 @@ public void save(CommandContext args, final CommandSender sender) throws Command
|
||||
.forRegionDataSave(world, false);
|
||||
} else {
|
||||
// Save for all worlds
|
||||
List<RegionManager> managers = new ArrayList<RegionManager>();
|
||||
List<RegionManager> managers = new ArrayList<>();
|
||||
|
||||
for (World w : Bukkit.getServer().getWorlds()) {
|
||||
RegionManager manager = plugin.getRegionContainer().get(w);
|
||||
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(w));
|
||||
if (manager != null) {
|
||||
managers.add(manager);
|
||||
}
|
||||
@ -896,7 +904,7 @@ public void save(CommandContext args, final CommandSender sender) throws Command
|
||||
desc = "Migrate from one Protection Database to another.", min = 2, max = 2)
|
||||
public void migrateDB(CommandContext args, CommandSender sender) throws CommandException {
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayMigrateRegionStore()) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayMigrateRegionStore()) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -920,7 +928,7 @@ public void migrateDB(CommandContext args, CommandSender sender) throws CommandE
|
||||
"Please ensure you have made a backup of your data, and then re-enter the command with -y tacked on at the end to proceed.");
|
||||
}
|
||||
|
||||
ConfigurationManager config = plugin.getGlobalStateManager();
|
||||
ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
RegionDriver fromDriver = config.regionStoreDriverMap.get(from);
|
||||
RegionDriver toDriver = config.regionStoreDriverMap.get(to);
|
||||
|
||||
@ -932,7 +940,7 @@ public void migrateDB(CommandContext args, CommandSender sender) throws CommandE
|
||||
throw new CommandException("The driver specified as 'to' does not seem to be supported in your version of WorldGuard.");
|
||||
}
|
||||
|
||||
DriverMigration migration = new DriverMigration(fromDriver, toDriver, plugin.getFlagRegistry());
|
||||
DriverMigration migration = new DriverMigration(fromDriver, toDriver, WorldGuard.getInstance().getFlagRegistry());
|
||||
|
||||
LoggerToChatHandler handler = null;
|
||||
Logger minecraftLogger = null;
|
||||
@ -945,7 +953,7 @@ public void migrateDB(CommandContext args, CommandSender sender) throws CommandE
|
||||
}
|
||||
|
||||
try {
|
||||
BukkitRegionContainer container = plugin.getRegionContainer();
|
||||
BukkitRegionContainer container = (BukkitRegionContainer) WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
sender.sendMessage(ChatColor.YELLOW + "Now performing migration... this may take a while.");
|
||||
container.migrate(migration);
|
||||
sender.sendMessage(ChatColor.YELLOW +
|
||||
@ -973,7 +981,7 @@ public void migrateDB(CommandContext args, CommandSender sender) throws CommandE
|
||||
desc = "Migrate loaded databases to use UUIDs", max = 0)
|
||||
public void migrateUuid(CommandContext args, CommandSender sender) throws CommandException {
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayMigrateRegionNames()) {
|
||||
if (!getPermissionModel(plugin.getWorldEdit().wrapCommandSender(sender)).mayMigrateRegionNames()) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@ -988,10 +996,10 @@ public void migrateUuid(CommandContext args, CommandSender sender) throws Comman
|
||||
}
|
||||
|
||||
try {
|
||||
ConfigurationManager config = plugin.getGlobalStateManager();
|
||||
BukkitRegionContainer container = plugin.getRegionContainer();
|
||||
ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitRegionContainer container = (BukkitRegionContainer) WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionDriver driver = container.getDriver();
|
||||
UUIDMigration migration = new UUIDMigration(driver, plugin.getProfileService(), plugin.getFlagRegistry());
|
||||
UUIDMigration migration = new UUIDMigration(driver, plugin.getProfileService(), WorldGuard.getInstance().getFlagRegistry());
|
||||
migration.setKeepUnresolvedNames(config.keepUnresolvedNames);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Now performing migration... this may take a while.");
|
||||
container.migrate(migration);
|
||||
@ -1020,14 +1028,15 @@ public void migrateUuid(CommandContext args, CommandSender sender) throws Comman
|
||||
min = 1, max = 1)
|
||||
public void teleport(CommandContext args, CommandSender sender) throws CommandException {
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
Location teleportLocation;
|
||||
|
||||
// Lookup the existing region
|
||||
RegionManager regionManager = checkRegionManager(plugin, player.getWorld());
|
||||
RegionManager regionManager = checkRegionManager(plugin, localPlayer.getWorld());
|
||||
ProtectedRegion existing = checkExistingRegion(regionManager, args.getString(0), false);
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).mayTeleportTo(existing)) {
|
||||
if (!getPermissionModel(localPlayer).mayTeleportTo(existing)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,23 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands.region;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldguard.bukkit.BukkitRegionContainer;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
@ -42,6 +47,7 @@
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -61,7 +67,7 @@ protected RegionCommandsBase() {
|
||||
* @param sender the sender
|
||||
* @return the permission model
|
||||
*/
|
||||
protected static RegionPermissionModel getPermissionModel(CommandSender sender) {
|
||||
protected static RegionPermissionModel getPermissionModel(Actor sender) {
|
||||
return new RegionPermissionModel(sender);
|
||||
}
|
||||
|
||||
@ -154,7 +160,7 @@ protected static ProtectedRegion checkExistingRegion(RegionManager regionManager
|
||||
* @return a region
|
||||
* @throws CommandException thrown if no region was found
|
||||
*/
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, Player player) throws CommandException {
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player) throws CommandException {
|
||||
return checkRegionStandingIn(regionManager, player, false);
|
||||
}
|
||||
|
||||
@ -173,13 +179,13 @@ protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManag
|
||||
* @return a region
|
||||
* @throws CommandException thrown if no region was found
|
||||
*/
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, Player player, boolean allowGlobal) throws CommandException {
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(player.getLocation());
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal) throws CommandException {
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(player.getLocation().toVector());
|
||||
|
||||
if (set.size() == 0) {
|
||||
if (allowGlobal) {
|
||||
ProtectedRegion global = checkExistingRegion(regionManager, "__global__", true);
|
||||
player.sendMessage(ChatColor.GRAY + "You're not standing in any " +
|
||||
player.printDebug("You're not standing in any " +
|
||||
"regions. Using the global region for this world instead.");
|
||||
return global;
|
||||
}
|
||||
@ -213,18 +219,17 @@ protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManag
|
||||
* @return the selection
|
||||
* @throws CommandException thrown on an error
|
||||
*/
|
||||
protected static Selection checkSelection(Player player) throws CommandException {
|
||||
protected static Region checkSelection(Player player) throws CommandException {
|
||||
WorldEditPlugin worldEdit = WorldGuardPlugin.inst().getWorldEdit();
|
||||
Selection selection = worldEdit.getSelection(player);
|
||||
|
||||
if (selection == null) {
|
||||
com.sk89q.worldedit.entity.Player wePlayer = worldEdit.wrapPlayer(player);
|
||||
try {
|
||||
return WorldEdit.getInstance().getSessionManager().get(wePlayer).getRegionSelector(wePlayer.getWorld()).getRegion();
|
||||
} catch (IncompleteRegionException e) {
|
||||
throw new CommandException(
|
||||
"Please select an area first. " +
|
||||
"Use WorldEdit to make a selection! " +
|
||||
"(wiki: http://wiki.sk89q.com/wiki/WorldEdit).");
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,14 +253,14 @@ protected static void checkRegionDoesNotExist(RegionManager manager, String id,
|
||||
* @param world the world
|
||||
* @throws CommandException thrown if the manager is null
|
||||
*/
|
||||
protected static RegionManager checkRegionManager(WorldGuardPlugin plugin, World world) throws CommandException {
|
||||
if (!plugin.getGlobalStateManager().get(world).useRegions) {
|
||||
protected static RegionManager checkRegionManager(WorldGuardPlugin plugin, com.sk89q.worldedit.world.World world) throws CommandException {
|
||||
if (!WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).useRegions) {
|
||||
throw new CommandException("Region support is disabled in the target world. " +
|
||||
"It can be enabled per-world in WorldGuard's configuration files. " +
|
||||
"However, you may need to restart your server afterwards.");
|
||||
}
|
||||
|
||||
RegionManager manager = plugin.getRegionContainer().get(world);
|
||||
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world);
|
||||
if (manager == null) {
|
||||
throw new CommandException("Region data failed to load for this world. " +
|
||||
"Please ask a server administrator to read the logs to identify the reason.");
|
||||
@ -272,17 +277,17 @@ protected static RegionManager checkRegionManager(WorldGuardPlugin plugin, World
|
||||
* @throws CommandException thrown on an error
|
||||
*/
|
||||
protected static ProtectedRegion checkRegionFromSelection(Player player, String id) throws CommandException {
|
||||
Selection selection = checkSelection(player);
|
||||
Region selection = checkSelection(player);
|
||||
|
||||
// Detect the type of region from WorldEdit
|
||||
if (selection instanceof Polygonal2DSelection) {
|
||||
Polygonal2DSelection polySel = (Polygonal2DSelection) selection;
|
||||
int minY = polySel.getNativeMinimumPoint().getBlockY();
|
||||
int maxY = polySel.getNativeMaximumPoint().getBlockY();
|
||||
return new ProtectedPolygonalRegion(id, polySel.getNativePoints(), minY, maxY);
|
||||
} else if (selection instanceof CuboidSelection) {
|
||||
BlockVector min = selection.getNativeMinimumPoint().toBlockVector();
|
||||
BlockVector max = selection.getNativeMaximumPoint().toBlockVector();
|
||||
if (selection instanceof Polygonal2DRegion) {
|
||||
Polygonal2DRegion polySel = (Polygonal2DRegion) selection;
|
||||
int minY = polySel.getMinimumPoint().getBlockY();
|
||||
int maxY = polySel.getMaximumPoint().getBlockY();
|
||||
return new ProtectedPolygonalRegion(id, polySel.getPoints(), minY, maxY);
|
||||
} else if (selection instanceof CuboidRegion) {
|
||||
BlockVector min = selection.getMinimumPoint().toBlockVector();
|
||||
BlockVector max = selection.getMaximumPoint().toBlockVector();
|
||||
return new ProtectedCuboidRegion(id, min, max);
|
||||
} else {
|
||||
throw new CommandException("Sorry, you can only use cuboids and polygons for WorldGuard regions.");
|
||||
@ -295,7 +300,7 @@ protected static ProtectedRegion checkRegionFromSelection(Player player, String
|
||||
* @param sender the sender to send the message to
|
||||
*/
|
||||
protected static void warnAboutSaveFailures(CommandSender sender) {
|
||||
BukkitRegionContainer container = WorldGuardPlugin.inst().getRegionContainer();
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
Set<RegionManager> failures = container.getSaveFailures();
|
||||
|
||||
if (failures.size() > 0) {
|
||||
@ -313,10 +318,10 @@ protected static void warnAboutSaveFailures(CommandSender sender) {
|
||||
* @param sender the sender to send the message to
|
||||
* @param region the region
|
||||
*/
|
||||
protected static void warnAboutDimensions(CommandSender sender, ProtectedRegion region) {
|
||||
protected static void warnAboutDimensions(Actor sender, ProtectedRegion region) {
|
||||
int height = region.getMaximumPoint().getBlockY() - region.getMinimumPoint().getBlockY();
|
||||
if (height <= 2) {
|
||||
sender.sendMessage(ChatColor.GRAY + "(Warning: The height of the region was " + (height + 1) + " block(s).)");
|
||||
sender.printDebug("(Warning: The height of the region was " + (height + 1) + " block(s).)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,25 +351,26 @@ protected static void informNewUser(CommandSender sender, RegionManager manager,
|
||||
*/
|
||||
protected static void setPlayerSelection(Player player, ProtectedRegion region) throws CommandException {
|
||||
WorldEditPlugin worldEdit = WorldGuardPlugin.inst().getWorldEdit();
|
||||
com.sk89q.worldedit.entity.Player wePlayer = worldEdit.wrapPlayer(player);
|
||||
|
||||
World world = player.getWorld();
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer);
|
||||
|
||||
// Set selection
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
ProtectedCuboidRegion cuboid = (ProtectedCuboidRegion) region;
|
||||
Vector pt1 = cuboid.getMinimumPoint();
|
||||
Vector pt2 = cuboid.getMaximumPoint();
|
||||
CuboidSelection selection = new CuboidSelection(world, pt1, pt2);
|
||||
worldEdit.setSelection(player, selection);
|
||||
|
||||
session.setRegionSelector(wePlayer.getWorld(), new CuboidRegionSelector(wePlayer.getWorld(), pt1, pt2));
|
||||
player.sendMessage(ChatColor.YELLOW + "Region selected as a cuboid.");
|
||||
|
||||
} else if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion poly2d = (ProtectedPolygonalRegion) region;
|
||||
Polygonal2DSelection selection = new Polygonal2DSelection(
|
||||
world, poly2d.getPoints(),
|
||||
Polygonal2DRegionSelector selector = new Polygonal2DRegionSelector(
|
||||
wePlayer.getWorld(), poly2d.getPoints(),
|
||||
poly2d.getMinimumPoint().getBlockY(),
|
||||
poly2d.getMaximumPoint().getBlockY() );
|
||||
worldEdit.setSelection(player, selection);
|
||||
session.setRegionSelector(wePlayer.getWorld(), selector);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region selected as a polygon.");
|
||||
|
||||
} else if (region instanceof GlobalProtectedRegion) {
|
||||
@ -387,7 +393,7 @@ protected static void setPlayerSelection(Player player, ProtectedRegion region)
|
||||
* @param value the value
|
||||
* @throws InvalidFlagFormat thrown if the value is invalid
|
||||
*/
|
||||
protected static <V> void setFlag(ProtectedRegion region, Flag<V> flag, CommandSender sender, String value) throws InvalidFlagFormat {
|
||||
protected static <V> void setFlag(ProtectedRegion region, Flag<V> flag, Actor sender, String value) throws InvalidFlagFormat {
|
||||
region.setFlag(flag, flag.parseInput(FlagContext.create().setSender(sender).setInput(value).setObject("region", region).build()));
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
import com.sk89q.squirrelid.cache.ProfileCache;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||
@ -29,12 +29,13 @@
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Create a region printout, as used in /region info to show information about
|
||||
* a region.
|
||||
@ -105,7 +106,7 @@ public void appendFlags() {
|
||||
public void appendFlagsList(boolean useColors) {
|
||||
boolean hasFlags = false;
|
||||
|
||||
for (Flag<?> flag : WorldGuardPlugin.inst().getFlagRegistry()) {
|
||||
for (Flag<?> flag : WorldGuard.getInstance().getFlagRegistry()) {
|
||||
Object val = region.getFlag(flag), group = null;
|
||||
|
||||
// No value
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.blacklist.target.ItemTarget;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcher;
|
||||
@ -55,19 +56,19 @@ public boolean test(Target target) {
|
||||
}
|
||||
|
||||
public boolean test(Material material) {
|
||||
return test(new ItemTarget(material));
|
||||
return test(new ItemTarget(BukkitAdapter.asItemType(material)));
|
||||
}
|
||||
|
||||
public boolean test(Block block) {
|
||||
return test(new ItemTarget(block.getTypeId(), block.getData()));
|
||||
return test(new ItemTarget(BukkitAdapter.asItemType(block.getType())));
|
||||
}
|
||||
|
||||
public boolean test(BlockState state) {
|
||||
return test(new ItemTarget(state.getType()));
|
||||
return test(new ItemTarget(BukkitAdapter.asItemType(state.getType())));
|
||||
}
|
||||
|
||||
public boolean test(ItemStack itemStack) {
|
||||
return test(new ItemTarget(itemStack.getTypeId()));
|
||||
return test(new ItemTarget(BukkitAdapter.asItemType(itemStack.getType())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
}
|
||||
|
||||
event.filter(target -> {
|
||||
if (wcfg.getChestProtection().isChest(BukkitAdapter.adapt(event.getEffectiveMaterial())) && wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()),
|
||||
if (wcfg.getChestProtection().isChest(BukkitAdapter.asBlockType(event.getEffectiveMaterial())) && wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()),
|
||||
WorldGuardPlugin.inst().wrapPlayer(player))) {
|
||||
sendMessage(event, player, ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for.");
|
||||
return false;
|
||||
|
@ -20,6 +20,8 @@
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
@ -70,6 +72,8 @@
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SpawnEggMeta;
|
||||
import org.bukkit.material.Dispenser;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.PistonExtensionMaterial;
|
||||
@ -247,7 +251,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
|
||||
if (event.isCancelled() && !wasCancelled && entity instanceof FallingBlock) {
|
||||
FallingBlock fallingBlock = (FallingBlock) entity;
|
||||
ItemStack itemStack = new ItemStack(fallingBlock.getMaterial(), 1, fallingBlock.getBlockData());
|
||||
ItemStack itemStack = new ItemStack(fallingBlock.getBlockData().getMaterial(), 1);
|
||||
Item item = block.getWorld().dropItem(fallingBlock.getLocation(), itemStack);
|
||||
item.setVelocity(new Vector());
|
||||
if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(block, entity), item))) {
|
||||
@ -281,8 +285,8 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
blocks = new ArrayList<>(event.getBlocks());
|
||||
} catch (NoSuchMethodError e) {
|
||||
blocks = Lists.newArrayList(event.getRetractLocation().getBlock());
|
||||
if (piston.getType() == Material.PISTON_MOVING_PIECE) {
|
||||
direction = new PistonExtensionMaterial(Material.PISTON_STICKY_BASE.getId(), piston.getData()).getFacing();
|
||||
if (piston.getType() == Material.MOVING_PISTON) {
|
||||
direction = new PistonExtensionMaterial(Material.STICKY_PISTON, piston.getData()).getFacing();
|
||||
}
|
||||
}
|
||||
int originalSize = blocks.size();
|
||||
@ -409,7 +413,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
// emit a "use block here" event where the player is
|
||||
// standing, which is a hack to protect items that don't
|
||||
// throw events
|
||||
if (item != null && getWorldConfig(player.getWorld()).blockUseAtFeet.test(item)) {
|
||||
if (item != null && getWorldConfig(BukkitAdapter.adapt(player.getWorld())).blockUseAtFeet.test(item)) {
|
||||
if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, player.getLocation().getBlock()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -516,7 +520,7 @@ public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
BukkitWorldConfiguration config = getWorldConfig(event.getBlock().getWorld());
|
||||
BukkitWorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getBlock().getWorld()));
|
||||
|
||||
// This only applies to regions but nothing else cares about high
|
||||
// frequency events at the moment
|
||||
@ -562,7 +566,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
case DISPENSE_EGG:
|
||||
case EGG:
|
||||
case SPAWNER_EGG:
|
||||
if (getWorldConfig(event.getEntity().getWorld()).strictEntitySpawn) {
|
||||
if (getWorldConfig(BukkitAdapter.adapt(event.getEntity().getWorld())).strictEntitySpawn) {
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, Cause.unknown(), event.getEntity()));
|
||||
}
|
||||
break;
|
||||
@ -655,7 +659,7 @@ public void onExpBottle(ExpBottleEvent event) {
|
||||
if (shooter instanceof Player) {
|
||||
Player player = (Player) shooter;
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.getInventory().addItem(new ItemStack(Material.EXP_BOTTLE, 1));
|
||||
player.getInventory().addItem(new ItemStack(Material.EXPERIENCE_BOTTLE, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -794,7 +798,8 @@ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
|
||||
InventoryHolder sourceHolder = event.getSource().getHolder();
|
||||
InventoryHolder targetHolder = event.getDestination().getHolder();
|
||||
|
||||
if (causeHolder instanceof Hopper && getPlugin().getGlobalStateManager().get(((Hopper) causeHolder).getWorld()).ignoreHopperMoveEvents) {
|
||||
if (causeHolder instanceof Hopper
|
||||
&& ((BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(((Hopper) causeHolder).getWorld()))).ignoreHopperMoveEvents) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -934,10 +939,10 @@ private static <T extends Event & Cancellable> void handleBlockRightClick(T even
|
||||
}
|
||||
|
||||
// Handle created spawn eggs
|
||||
if (item != null && item.getType() == Material.MONSTER_EGG) {
|
||||
MaterialData data = item.getData();
|
||||
if (data instanceof SpawnEgg) {
|
||||
@Nullable EntityType type = ((SpawnEgg) data).getSpawnedType();
|
||||
if (item != null && Materials.isSpawnEgg(item.getType())) {
|
||||
ItemMeta data = item.getItemMeta();
|
||||
if (data instanceof SpawnEggMeta) {
|
||||
@Nullable EntityType type = ((SpawnEggMeta) data).getSpawnedType();
|
||||
if (type == null) {
|
||||
type = EntityType.SHEEP; // Haven't investigated why it's sometimes null
|
||||
}
|
||||
@ -979,11 +984,11 @@ private static <T extends Event & Cancellable> void handleInventoryHolderUse(T o
|
||||
}
|
||||
|
||||
private boolean hasInteractBypass(Block block) {
|
||||
return getWorldConfig(block.getWorld()).allowAllInteract.test(block);
|
||||
return getWorldConfig(BukkitAdapter.adapt(block.getWorld())).allowAllInteract.test(block);
|
||||
}
|
||||
|
||||
private boolean hasInteractBypass(World world, ItemStack item) {
|
||||
return getWorldConfig(world).allowAllInteract.test(item);
|
||||
return getWorldConfig(BukkitAdapter.adapt(world)).allowAllInteract.test(item);
|
||||
}
|
||||
|
||||
private boolean isBlockModifiedOnClick(Block block, boolean rightClick) {
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
@ -54,19 +56,19 @@ public void registerEvents() {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
session.testMoveTo(player, event.getRespawnLocation(), MoveType.RESPAWN, true);
|
||||
session.testMoveTo(player, BukkitAdapter.adapt(event.getRespawnLocation()), MoveType.RESPAWN, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
Entity entity = event.getEntered();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
LocalPlayer player = plugin.wrapPlayer((Player) entity);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
if (null != session.testMoveTo(player, event.getVehicle().getLocation(), MoveType.EMBARK, true)) {
|
||||
if (null != session.testMoveTo(player, BukkitAdapter.adapt(event.getVehicle().getLocation()), MoveType.EMBARK, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -75,9 +77,10 @@ public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
final Location override = session.testMoveTo(player, event.getTo(), MoveType.MOVE);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
|
||||
final Location override = BukkitAdapter.adapt(session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), MoveType.MOVE));
|
||||
|
||||
if (override != null) {
|
||||
override.setX(override.getBlockX() + 0.5);
|
||||
|
@ -35,7 +35,7 @@
|
||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
|
||||
import com.sk89q.worldguard.bukkit.protection.DelayedRegionOverlapAssociation;
|
||||
import com.sk89q.worldguard.protection.DelayedRegionOverlapAssociation;
|
||||
import com.sk89q.worldguard.bukkit.protection.events.DisallowedPVPEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
@ -104,12 +104,13 @@ private void tellErrorMessage(DelegateEvent event, Cause cause, Location locatio
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
Player player = (Player) rootCause;
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
Long lastTime = WGMetadata.getIfPresent(player, DENY_MESSAGE_KEY, Long.class);
|
||||
if (lastTime == null || now - lastTime >= LAST_MESSAGE_DELAY) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
String message = query.queryValue(location, player, Flags.DENY_MESSAGE);
|
||||
String message = query.queryValue(BukkitAdapter.adapt(location), localPlayer, Flags.DENY_MESSAGE);
|
||||
if (message != null && !message.isEmpty()) {
|
||||
player.sendMessage(message.replace("%what%", what));
|
||||
}
|
||||
@ -158,10 +159,10 @@ private RegionAssociable createRegionAssociable(Cause cause) {
|
||||
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
|
||||
} else if (rootCause instanceof Entity) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
return new DelayedRegionOverlapAssociation(query, ((Entity) rootCause).getLocation());
|
||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Entity) rootCause).getLocation()));
|
||||
} else if (rootCause instanceof Block) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
return new DelayedRegionOverlapAssociation(query, ((Block) rootCause).getLocation());
|
||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Block) rootCause).getLocation()));
|
||||
} else {
|
||||
return Associables.constant(Association.NON_MEMBER);
|
||||
}
|
||||
@ -170,7 +171,7 @@ private RegionAssociable createRegionAssociable(Cause cause) {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
final Material type = event.getEffectiveMaterial();
|
||||
@ -180,52 +181,49 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
// Don't check liquid flow unless it's enabled
|
||||
if (event.getCause().getRootCause() instanceof Block
|
||||
&& Materials.isLiquid(type)
|
||||
&& !getWorldConfig(event.getWorld()).checkLiquidFlow) {
|
||||
&& !getWorldConfig(BukkitAdapter.adapt(event.getWorld())).checkLiquidFlow) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.filter(new Predicate<Location>() {
|
||||
@Override
|
||||
public boolean apply(Location target) {
|
||||
boolean canPlace;
|
||||
String what;
|
||||
event.filter((Predicate<Location>) target -> {
|
||||
boolean canPlace;
|
||||
String what;
|
||||
|
||||
/* Flint and steel, fire charge, etc. */
|
||||
if (type == Material.FIRE) {
|
||||
Block block = event.getCause().getFirstBlock();
|
||||
boolean fire = block != null && block.getType() == Material.FIRE;
|
||||
boolean lava = block != null && Materials.isLava(block.getType());
|
||||
List<StateFlag> flags = new ArrayList<StateFlag>();
|
||||
flags.add(Flags.BLOCK_PLACE);
|
||||
flags.add(Flags.LIGHTER);
|
||||
if (fire) flags.add(Flags.FIRE_SPREAD);
|
||||
if (lava) flags.add(Flags.LAVA_FIRE);
|
||||
canPlace = query.testBuild(target, associable, combine(event, flags.toArray(new StateFlag[flags.size()])));
|
||||
what = "place fire";
|
||||
/* Flint and steel, fire charge, etc. */
|
||||
if (type == Material.FIRE) {
|
||||
Block block = event.getCause().getFirstBlock();
|
||||
boolean fire = block != null && block.getType() == Material.FIRE;
|
||||
boolean lava = block != null && Materials.isLava(block.getType());
|
||||
List<StateFlag> flags = new ArrayList<>();
|
||||
flags.add(Flags.BLOCK_PLACE);
|
||||
flags.add(Flags.LIGHTER);
|
||||
if (fire) flags.add(Flags.FIRE_SPREAD);
|
||||
if (lava) flags.add(Flags.LAVA_FIRE);
|
||||
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, flags.toArray(new StateFlag[flags.size()])));
|
||||
what = "place fire";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canPlace = query.testBuild(target, associable, combine(event, Flags.BLOCK_PLACE));
|
||||
try {
|
||||
event.setSilent(type == Material.FROSTED_ICE);
|
||||
} catch (NoSuchFieldError ignored) {} // back compat
|
||||
what = "place that block";
|
||||
}
|
||||
|
||||
if (!canPlace) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
/* Everything else */
|
||||
} else {
|
||||
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_PLACE));
|
||||
try {
|
||||
event.setSilent(type == Material.FROSTED_ICE);
|
||||
} catch (NoSuchFieldError ignored) {} // back compat
|
||||
what = "place that block";
|
||||
}
|
||||
|
||||
if (!canPlace) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBreakBlock(final BreakBlockEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
final RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
@ -233,30 +231,27 @@ public void onBreakBlock(final BreakBlockEvent event) {
|
||||
if (!event.isCancelled()) {
|
||||
final RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
event.filter(new Predicate<Location>() {
|
||||
@Override
|
||||
public boolean apply(Location target) {
|
||||
boolean canBreak;
|
||||
String what;
|
||||
event.filter((Predicate<Location>) target -> {
|
||||
boolean canBreak;
|
||||
String what;
|
||||
|
||||
/* TNT */
|
||||
if (event.getCause().find(EntityType.PRIMED_TNT, EntityType.MINECART_TNT) != null) {
|
||||
canBreak = query.testBuild(target, associable, combine(event, Flags.BLOCK_BREAK, Flags.TNT));
|
||||
what = "use dynamite";
|
||||
/* TNT */
|
||||
if (event.getCause().find(EntityType.PRIMED_TNT, EntityType.MINECART_TNT) != null) {
|
||||
canBreak = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_BREAK, Flags.TNT));
|
||||
what = "use dynamite";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canBreak = query.testBuild(target, associable, combine(event, Flags.BLOCK_BREAK));
|
||||
what = "break that block";
|
||||
}
|
||||
|
||||
if (!canBreak) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
/* Everything else */
|
||||
} else {
|
||||
canBreak = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_BREAK));
|
||||
what = "break that block";
|
||||
}
|
||||
|
||||
if (!canBreak) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -264,64 +259,61 @@ public boolean apply(Location target) {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseBlock(final UseBlockEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
final Material type = event.getEffectiveMaterial();
|
||||
final RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
final RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
event.filter(new Predicate<Location>() {
|
||||
@Override
|
||||
public boolean apply(Location target) {
|
||||
boolean canUse;
|
||||
String what;
|
||||
event.filter((Predicate<Location>) target -> {
|
||||
boolean canUse;
|
||||
String what;
|
||||
|
||||
/* Saplings, etc. */
|
||||
if (Materials.isConsideredBuildingIfUsed(type)) {
|
||||
canUse = query.testBuild(target, associable, combine(event));
|
||||
what = "use that";
|
||||
/* Saplings, etc. */
|
||||
if (Materials.isConsideredBuildingIfUsed(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
what = "use that";
|
||||
|
||||
/* Inventory */
|
||||
} else if (Materials.isInventoryBlock(type)) {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.INTERACT, Flags.CHEST_ACCESS));
|
||||
what = "open that";
|
||||
/* Inventory */
|
||||
} else if (Materials.isInventoryBlock(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.CHEST_ACCESS));
|
||||
what = "open that";
|
||||
|
||||
/* Beds */
|
||||
} else if (type == Material.BED_BLOCK) {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.INTERACT, Flags.SLEEP));
|
||||
what = "sleep";
|
||||
/* Beds */
|
||||
} else if (Materials.isBed(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.SLEEP));
|
||||
what = "sleep";
|
||||
|
||||
/* TNT */
|
||||
} else if (type == Material.TNT) {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.INTERACT, Flags.TNT));
|
||||
what = "use explosives";
|
||||
/* TNT */
|
||||
} else if (type == Material.TNT) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.TNT));
|
||||
what = "use explosives";
|
||||
|
||||
/* Legacy USE flag */
|
||||
} else if (Materials.isUseFlagApplicable(type)) {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.INTERACT, Flags.USE));
|
||||
what = "use that";
|
||||
/* Legacy USE flag */
|
||||
} else if (Materials.isUseFlagApplicable(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.USE));
|
||||
what = "use that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.INTERACT));
|
||||
what = "use that";
|
||||
}
|
||||
|
||||
if (!canUse) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
/* Everything else */
|
||||
} else {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT));
|
||||
what = "use that";
|
||||
}
|
||||
|
||||
if (!canUse) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
Location target = event.getTarget();
|
||||
@ -335,26 +327,26 @@ public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
|
||||
/* Vehicles */
|
||||
if (Entities.isVehicle(type)) {
|
||||
canSpawn = query.testBuild(target, associable, combine(event, Flags.PLACE_VEHICLE));
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.PLACE_VEHICLE));
|
||||
what = "place vehicles";
|
||||
|
||||
/* Item pickup */
|
||||
} else if (event.getEntity() instanceof Item) {
|
||||
canSpawn = query.testBuild(target, associable, combine(event, Flags.ITEM_DROP));
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.ITEM_DROP));
|
||||
what = "drop items";
|
||||
|
||||
/* XP drops */
|
||||
} else if (type == EntityType.EXPERIENCE_ORB) {
|
||||
canSpawn = query.testBuild(target, associable, combine(event, Flags.EXP_DROPS));
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.EXP_DROPS));
|
||||
what = "drop XP";
|
||||
|
||||
} else if (Entities.isAoECloud(type)) {
|
||||
canSpawn = query.testBuild(target, associable, combine(event, Flags.POTION_SPLASH));
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.POTION_SPLASH));
|
||||
what = "use lingering potions";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canSpawn = query.testBuild(target, associable, combine(event));
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
|
||||
if (event.getEntity() instanceof Item) {
|
||||
what = "drop items";
|
||||
@ -372,7 +364,7 @@ public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
Location target = event.getTarget();
|
||||
@ -385,17 +377,17 @@ public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
|
||||
/* Vehicles */
|
||||
if (Entities.isVehicle(type)) {
|
||||
canDestroy = query.testBuild(target, associable, combine(event, Flags.DESTROY_VEHICLE));
|
||||
canDestroy = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.DESTROY_VEHICLE));
|
||||
what = "break vehicles";
|
||||
|
||||
/* Item pickup */
|
||||
} else if (event.getEntity() instanceof Item || event.getEntity() instanceof ExperienceOrb) {
|
||||
canDestroy = query.testBuild(target, associable, combine(event, Flags.ITEM_PICKUP));
|
||||
canDestroy = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.ITEM_PICKUP));
|
||||
what = "pick up items";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canDestroy = query.testBuild(target, associable, combine(event));
|
||||
canDestroy = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
what = "break things";
|
||||
}
|
||||
|
||||
@ -408,7 +400,7 @@ public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseEntity(UseEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
Location target = event.getTarget();
|
||||
@ -421,22 +413,22 @@ public void onUseEntity(UseEntityEvent event) {
|
||||
/* Hostile / ambient mob override */
|
||||
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())
|
||||
|| Entities.isNPC(event.getEntity()) || Entities.isVehicle(event.getEntity().getType())) {
|
||||
canUse = event.getRelevantFlags().isEmpty() || query.queryState(target, associable, combine(event)) != State.DENY;
|
||||
canUse = event.getRelevantFlags().isEmpty() || query.queryState(BukkitAdapter.adapt(target), associable, combine(event)) != State.DENY;
|
||||
what = "use that";
|
||||
|
||||
/* Paintings, item frames, etc. */
|
||||
} else if (Entities.isConsideredBuildingIfUsed(event.getEntity())) {
|
||||
canUse = query.testBuild(target, associable, combine(event));
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
what = "change that";
|
||||
|
||||
/* Ridden on use */
|
||||
} else if (Entities.isRiddenOnUse(event.getEntity())) {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.RIDE, Flags.INTERACT));
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.RIDE, Flags.INTERACT));
|
||||
what = "ride that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canUse = query.testBuild(target, associable, combine(event, Flags.INTERACT));
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT));
|
||||
what = "use that";
|
||||
}
|
||||
|
||||
@ -449,7 +441,7 @@ public void onUseEntity(UseEntityEvent event) {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDamageEntity(DamageEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
// Whitelist check is below
|
||||
|
||||
com.sk89q.worldedit.util.Location target = BukkitAdapter.adapt(event.getTarget());
|
||||
|
@ -112,7 +112,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
if (!wcfg.itemDurability) {
|
||||
ItemStack held = player.getItemInHand();
|
||||
if (held.getType() != Material.AIR && !(ItemType.usesDamageValue(held.getTypeId())|| BlockType.usesData(held.getTypeId()))) {
|
||||
if (held.getType() != Material.AIR) {
|
||||
held.setDurability((short) 0);
|
||||
player.setItemInHand(held);
|
||||
}
|
||||
@ -198,8 +198,7 @@ public void onBlockFromTo(BlockFromToEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.highFreqFlags && isLava
|
||||
&& !plugin.getGlobalRegionManager().allows(Flags.LAVA_FLOW,
|
||||
BukkitAdapter.adapt(blockFrom.getLocation()))) {
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(blockFrom.getLocation()), (RegionAssociable) null, Flags.LAVA_FLOW))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -485,8 +484,7 @@ public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(Flags.LEAF_DECAY,
|
||||
BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.LEAF_DECAY))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -19,28 +19,58 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.*;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityCreatePortalEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.PigZapEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
@ -77,7 +107,7 @@ public void onEntityInteract(EntityInteractEvent event) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(entity.getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
|
||||
if (block.getType() == Material.FARMLAND) {
|
||||
if (/* entity instanceof Creature && // catch for any entity (not thrown for players) */
|
||||
@ -89,7 +119,8 @@ public void onEntityInteract(EntityInteractEvent event) {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
BukkitWorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(event.getEntity().getWorld());
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
if (event instanceof PlayerDeathEvent && wcfg.disableDeathMessages) {
|
||||
((PlayerDeathEvent) event).setDeathMessage("");
|
||||
@ -101,7 +132,7 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
DamageCause type = event.getCause();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(defender.getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
|
||||
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
||||
if (wcfg.antiWolfDumbness && !(type == DamageCause.VOID)) {
|
||||
@ -148,7 +179,7 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
if (type == DamageCause.BLOCK_EXPLOSION
|
||||
&& (wcfg.blockOtherExplosions
|
||||
|| (wcfg.explosionFlagCancellation
|
||||
&& !plugin.getGlobalRegionManager().allows(Flags.OTHER_EXPLOSION, defender.getLocation())))) {
|
||||
&& !plugin.getGlobalRegionManager().allows(Flags.OTHER_EXPLOSION, BukkitAdapter.adapt(defender.getLocation()))))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -165,7 +196,8 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
BukkitWorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(defender.getWorld());
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
|
||||
if (defender instanceof ItemFrame) {
|
||||
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
||||
@ -183,7 +215,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
// this isn't handled elsewhere because ender crystal explosions don't carry a player cause
|
||||
// in the same way that creepers or tnt can
|
||||
if (wcfg.useRegions && wcfg.explosionFlagCancellation) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(defender.getLocation())
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(defender.getLocation()))
|
||||
.testState(null, Flags.OTHER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -230,7 +262,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(defender.getLocation());
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
if (!set.allows(Flags.MOB_DAMAGE, localPlayer) && !(attacker instanceof Tameable)) {
|
||||
event.setCancelled(true);
|
||||
@ -260,7 +292,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(defender.getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
@ -273,7 +305,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(defender.getLocation()).allows(Flags.MOB_DAMAGE, localPlayer)) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation()).allows(Flags.MOB_DAMAGE, localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -293,7 +325,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
if (!query.testState(defender.getLocation(), (Player) defender, Flags.GHAST_FIREBALL) && wcfg.explosionFlagCancellation) {
|
||||
if (!query.testState(localPlayer.getLocation(), localPlayer, Flags.GHAST_FIREBALL) && wcfg.explosionFlagCancellation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -329,7 +361,7 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
DamageCause type = event.getCause();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(defender.getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
|
||||
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
||||
if (wcfg.antiWolfDumbness) {
|
||||
@ -348,7 +380,7 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(defender.getLocation());
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
if (!set.allows(Flags.MOB_DAMAGE, plugin.wrapPlayer(player))) {
|
||||
event.setCancelled(true);
|
||||
@ -412,7 +444,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
Location l = event.getLocation();
|
||||
World world = l.getWorld();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
@ -469,7 +501,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
// allow wither skull blocking since there is no dedicated flag atm
|
||||
if (wcfg.useRegions) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(block.getLocation()).allows(Flags.GHAST_FIREBALL)) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation())).allows(Flags.GHAST_FIREBALL)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -487,7 +519,8 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (!plugin.getGlobalRegionManager().allows(Flags.WITHER_DAMAGE, block.getLocation())) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(block.getLocation()),
|
||||
(RegionAssociable) null, Flags.WITHER_DAMAGE))) {
|
||||
event.blockList().clear();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -501,9 +534,8 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
for (Block block : event.blockList()) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(block.getLocation()).allows(Flags.OTHER_EXPLOSION)) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation())).allows(Flags.OTHER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -515,7 +547,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
if (wcfg.signChestProtection) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (wcfg.isChestProtected(block)) {
|
||||
if (wcfg.isChestProtected(BukkitAdapter.adapt(block.getLocation()))) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
@ -530,7 +562,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
@ -577,7 +609,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitWorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
// allow spawning of creatures from plugins
|
||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
@ -605,14 +637,15 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
Location eventLoc = event.getLocation();
|
||||
|
||||
if (wcfg.useRegions && cfg.useRegionsCreatureSpawnEvent) {
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(eventLoc);
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(eventLoc));
|
||||
|
||||
if (!set.allows(Flags.MOB_SPAWNING)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Set<EntityType> entityTypes = set.getFlag(Flags.DENY_SPAWN);
|
||||
Set<com.sk89q.worldedit.world.entity.EntityType> entityTypes = set.getFlag(Flags.DENY_SPAWN);
|
||||
if (entityTypes != null && entityTypes.contains(entityType)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -630,7 +663,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onCreatePortal(EntityCreatePortalEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
switch (event.getEntityType()) {
|
||||
case ENDER_DRAGON:
|
||||
@ -642,7 +675,7 @@ public void onCreatePortal(EntityCreatePortalEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPigZap(PigZapEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
if (wcfg.disablePigZap) {
|
||||
event.setCancelled(true);
|
||||
@ -652,7 +685,7 @@ public void onPigZap(PigZapEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onCreeperPower(CreeperPowerEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
if (wcfg.disableCreeperPower) {
|
||||
event.setCancelled(true);
|
||||
@ -666,7 +699,7 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
World world = ent.getWorld();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (wcfg.disableHealthRegain) {
|
||||
event.setCancelled(true);
|
||||
@ -686,7 +719,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
Location location = block.getLocation();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(ent.getWorld());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(ent.getWorld()));
|
||||
if (ent instanceof Enderman) {
|
||||
if (wcfg.disableEndermanGriefing) {
|
||||
event.setCancelled(true);
|
||||
@ -694,7 +727,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(Flags.ENDER_BUILD, location)) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(location), (RegionAssociable) null, Flags.ENDER_BUILD))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -705,7 +738,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(Flags.WITHER_DAMAGE, location)) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(location), (RegionAssociable) null, Flags.WITHER_DAMAGE))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -728,13 +761,11 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
private boolean checkItemFrameProtection(Entity attacker, ItemFrame defender) {
|
||||
World world = attacker.getWorld();
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
if (wcfg.useRegions) {
|
||||
// bukkit throws this event when a player attempts to remove an item from a frame
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
// bukkit throws this event when a player attempts to remove an item from a frame
|
||||
if (!(attacker instanceof Player)) {
|
||||
if (!plugin.getGlobalRegionManager().allows(
|
||||
Flags.ENTITY_ITEM_FRAME_DESTROY, defender.getLocation())) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(defender.getLocation()), (RegionAssociable) null, Flags.ENTITY_ITEM_FRAME_DESTROY))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,9 @@
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -89,8 +91,7 @@ public void onHangingBreak(HangingBreakEvent event) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(Flags.CREEPER_EXPLOSION,
|
||||
BukkitAdapter.adapt(hanging.getLocation()))) {
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(hanging.getLocation()), (RegionAssociable) null, Flags.CREEPER_EXPLOSION))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -101,12 +102,12 @@ public void onHangingBreak(HangingBreakEvent event) {
|
||||
if (hanging instanceof Painting
|
||||
&& (wcfg.blockEntityPaintingDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(Flags.ENTITY_PAINTING_DESTROY, BukkitAdapter.adapt(hanging.getLocation()))))) {
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(hanging.getLocation()), (RegionAssociable) null, Flags.ENTITY_PAINTING_DESTROY))))) {
|
||||
event.setCancelled(true);
|
||||
} else if (hanging instanceof ItemFrame
|
||||
&& (wcfg.blockEntityItemFrameDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(Flags.ENTITY_ITEM_FRAME_DESTROY, BukkitAdapter.adapt(hanging.getLocation()))))) {
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(hanging.getLocation()), (RegionAssociable) null, Flags.ENTITY_ITEM_FRAME_DESTROY))))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -19,18 +19,19 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
@ -39,8 +40,8 @@
|
||||
import com.sk89q.worldguard.session.handler.GameModeFlag;
|
||||
import com.sk89q.worldguard.util.command.CommandFilter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TravelAgent;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -64,12 +65,13 @@
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a player.
|
||||
*/
|
||||
@ -99,13 +101,16 @@ public void registerEvents() {
|
||||
@EventHandler
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BukkitWorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(player.getWorld());
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().getIfPresent(player);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().getIfPresent(localPlayer);
|
||||
if (session != null) {
|
||||
GameModeFlag handler = session.getHandler(GameModeFlag.class);
|
||||
if (handler != null && wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
|
||||
if (handler != null && wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer,
|
||||
localPlayer.getWorld())) {
|
||||
GameMode expected = handler.getSetGameMode();
|
||||
if (handler.getOriginalGameMode() != null && expected != null && expected != event.getNewGameMode()) {
|
||||
if (handler.getOriginalGameMode() != null && expected != null && expected != BukkitAdapter.adapt(event.getNewGameMode())) {
|
||||
log.info("Game mode change on " + player.getName() + " has been blocked due to the region GAMEMODE flag");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -116,10 +121,11 @@ public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
World world = player.getWorld();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
@ -147,7 +153,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
|
||||
Events.fire(new ProcessPlayerEvent(player));
|
||||
|
||||
WorldGuard.getInstance().getPlatform().getSessionManager().get(player); // Initializes a session
|
||||
WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer); // Initializes a session
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -157,7 +163,7 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
BukkitWorldConfiguration wcfg =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(Flags.SEND_CHAT, localPlayer.getLocation(), localPlayer)) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(localPlayer.getLocation(), localPlayer, Flags.SEND_CHAT))) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to chat in this region!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -166,7 +172,7 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
for (Iterator<Player> i = event.getRecipients().iterator(); i.hasNext();) {
|
||||
Player rPlayer = i.next();
|
||||
LocalPlayer rLocal = plugin.wrapPlayer(rPlayer);
|
||||
if (!plugin.getGlobalRegionManager().allows(Flags.RECEIVE_CHAT, rLocal.getLocation(), rLocal)) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(rLocal.getLocation(), rLocal, Flags.RECEIVE_CHAT))) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
@ -246,21 +252,22 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
World world = block.getWorld();
|
||||
int type = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
Player player = event.getPlayer();
|
||||
@Nullable ItemStack item = event.getItem();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
// Infinite stack removal
|
||||
if ((type == BlockID.CHEST
|
||||
|| type == BlockID.JUKEBOX
|
||||
|| type == BlockID.DISPENSER
|
||||
|| type == BlockID.FURNACE
|
||||
|| type == BlockID.BURNING_FURNACE
|
||||
|| type == BlockID.BREWING_STAND
|
||||
|| type == BlockID.ENCHANTMENT_TABLE)
|
||||
if ((type == Material.CHEST
|
||||
|| type == Material.JUKEBOX
|
||||
|| type == Material.DISPENSER
|
||||
|| type == Material.FURNACE
|
||||
|| type == Material.DROPPER
|
||||
|| type == Material.BREWING_STAND
|
||||
|| type == Material.TRAPPED_CHEST
|
||||
|| type == Material.ENCHANTING_TABLE)
|
||||
&& wcfg.removeInfiniteStacks
|
||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||
for (int slot = 0; slot < 40; slot++) {
|
||||
@ -274,11 +281,12 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
//Block placedIn = block.getRelative(event.getBlockFace());
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
|
||||
//ApplicableRegionSet placedInSet = plugin.getRegionContainer().createQuery().getApplicableRegions(placedIn.getLocation());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (item != null && item.getTypeId() == wcfg.regionWand && plugin.hasPermission(player, "worldguard.region.wand")) {
|
||||
if (item != null && item.getType().getKey().toString().equals(wcfg.regionWand) && plugin.hasPermission(player, "worldguard.region.wand")) {
|
||||
if (set.size() > 0) {
|
||||
player.sendMessage(ChatColor.YELLOW + "Can you build? "
|
||||
+ (set.canBuild(localPlayer) ? "Yes" : "No"));
|
||||
@ -314,10 +322,10 @@ private void handlePhysicalInteract(PlayerInteractEvent event) {
|
||||
//int type = block.getTypeId();
|
||||
World world = player.getWorld();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (block.getTypeId() == BlockID.SOIL && wcfg.disablePlayerCropTrampling) {
|
||||
if (block.getType() == Material.FARMLAND && wcfg.disablePlayerCropTrampling) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -328,17 +336,18 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = player.getLocation();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().getApplicableRegions(location);
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(location));
|
||||
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
com.sk89q.worldedit.Location spawn = set.getFlag(Flags.SPAWN_LOC, localPlayer);
|
||||
com.sk89q.worldedit.util.Location spawn = set.getFlag(Flags.SPAWN_LOC, localPlayer);
|
||||
|
||||
if (spawn != null) {
|
||||
event.setRespawnLocation(com.sk89q.worldedit.bukkit.BukkitUtil.toLocation(spawn));
|
||||
event.setRespawnLocation(BukkitAdapter.adapt(spawn));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,8 +356,8 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
||||
|
||||
if (wcfg.removeInfiniteStacks
|
||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||
@ -365,23 +374,27 @@ public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
World world = event.getFrom().getWorld();
|
||||
Player player = event.getPlayer();
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().getApplicableRegions(event.getTo());
|
||||
ApplicableRegionSet setFrom = plugin.getRegionContainer().createQuery().getApplicableRegions(event.getFrom());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getTo()));
|
||||
ApplicableRegionSet setFrom =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getFrom()));
|
||||
|
||||
if (cfg.usePlayerTeleports) {
|
||||
if (null != plugin.getSessionManager().get(player).testMoveTo(player, event.getTo(), MoveType.TELEPORT)) {
|
||||
if (null != WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer).testMoveTo(localPlayer,
|
||||
BukkitAdapter.adapt(event.getTo()),
|
||||
MoveType.TELEPORT)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())
|
||||
&& !(set.allows(Flags.ENDERPEARL, localPlayer)
|
||||
&& setFrom.allows(Flags.ENDERPEARL, localPlayer))) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to go there.");
|
||||
@ -391,7 +404,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
}
|
||||
try {
|
||||
if (event.getCause() == TeleportCause.CHORUS_FRUIT) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
||||
boolean allowFrom = setFrom.allows(Flags.CHORUS_TELEPORT, localPlayer);
|
||||
boolean allowTo = set.allows(Flags.CHORUS_TELEPORT, localPlayer);
|
||||
if (!allowFrom || !allowTo) {
|
||||
@ -411,8 +424,9 @@ public void onPlayerPortal(PlayerPortalEvent event) {
|
||||
if (event.getTo() == null) { // apparently this counts as a cancelled event, implementation specific though
|
||||
return;
|
||||
}
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(event.getTo().getWorld());
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getTo().getWorld()));
|
||||
if (!wcfg.regionNetherPortalProtection) return;
|
||||
if (event.getCause() != TeleportCause.NETHER_PORTAL) {
|
||||
return;
|
||||
@ -434,12 +448,13 @@ public void onPlayerPortal(PlayerPortalEvent event) {
|
||||
int radius = pta.getCreationRadius();
|
||||
Location min = event.getTo().clone().subtract(radius, radius, radius);
|
||||
Location max = event.getTo().clone().add(radius, radius, radius);
|
||||
World world = event.getTo().getWorld();
|
||||
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(event.getTo().getWorld());
|
||||
|
||||
ProtectedRegion check = new ProtectedCuboidRegion("__portalcheck__", BukkitUtil.toVector(min.getBlock()), BukkitUtil.toVector(max.getBlock()));
|
||||
ProtectedRegion check = new ProtectedCuboidRegion("__portalcheck__", BukkitAdapter.adapt(min.getBlock().getLocation()).toVector().toBlockVector(),
|
||||
BukkitAdapter.adapt(max.getBlock().getLocation()).toVector().toBlockVector());
|
||||
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(event.getPlayer(), world)) {
|
||||
RegionManager mgr = plugin.getRegionContainer().get(event.getTo().getWorld());
|
||||
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, world)) {
|
||||
RegionManager mgr = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world);
|
||||
if (mgr == null) return;
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(check);
|
||||
if (!set.testState(plugin.wrapPlayer(event.getPlayer()), Flags.BUILD)) {
|
||||
@ -454,12 +469,12 @@ public void onPlayerPortal(PlayerPortalEvent event) {
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
World world = player.getWorld();
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = cfg.get(world);
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, world)) {
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
|
||||
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
Set<String> allowedCommands = set.queryValue(localPlayer, Flags.ALLOWED_CMDS);
|
||||
Set<String> blockedCommands = set.queryValue(localPlayer, Flags.BLOCKED_CMDS);
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -46,14 +47,14 @@ public void registerEvents() {
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
|
||||
WorldGuard.getInstance().getPlatform().getGlobalStateManager().updateCommandBookGodMode();
|
||||
((BukkitConfigurationManager) WorldGuard.getInstance().getPlatform().getGlobalStateManager()).updateCommandBookGodMode();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
|
||||
WorldGuard.getInstance().getPlatform().getGlobalStateManager().updateCommandBookGodMode();
|
||||
((BukkitConfigurationManager) WorldGuard.getInstance().getPlatform().getGlobalStateManager()).updateCommandBookGodMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
@ -34,6 +35,9 @@
|
||||
import org.bukkit.event.vehicle.VehicleMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WorldGuardVehicleListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
@ -57,18 +61,26 @@ public void registerEvents() {
|
||||
@EventHandler
|
||||
public void onVehicleMove(VehicleMoveEvent event) {
|
||||
Vehicle vehicle = event.getVehicle();
|
||||
if (vehicle.getPassenger() == null || !(vehicle.getPassenger() instanceof Player)) return;
|
||||
Player player = (Player) vehicle.getPassenger();
|
||||
if (vehicle.getPassengers().isEmpty()) return;
|
||||
List<LocalPlayer> playerPassengers =
|
||||
vehicle.getPassengers().stream().filter(ent -> ent instanceof Player).map(ent -> plugin.wrapPlayer((Player) ent)).collect(Collectors.toList());
|
||||
if (playerPassengers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
World world = vehicle.getWorld();
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
// Did we move a block?
|
||||
if (Locations.isDifferentBlock(event.getFrom(), event.getTo())) {
|
||||
if (null != WorldGuard.getInstance().getPlatform().getSessionManager().get(player).testMoveTo(player, event.getTo(), MoveType.RIDE)) {
|
||||
vehicle.setVelocity(new Vector(0,0,0));
|
||||
vehicle.teleport(event.getFrom());
|
||||
if (Locations.isDifferentBlock(BukkitAdapter.adapt(event.getFrom()), BukkitAdapter.adapt(event.getTo()))) {
|
||||
for (LocalPlayer player : playerPassengers) {
|
||||
if (null != WorldGuard.getInstance().getPlatform().getSessionManager().get(player)
|
||||
.testMoveTo(player, BukkitAdapter.adapt(event.getTo()), MoveType.RIDE)) {
|
||||
vehicle.setVelocity(new Vector(0, 0, 0));
|
||||
vehicle.teleport(event.getFrom());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.session;
|
||||
package com.sk89q.worldguard.bukkit.session;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
@ -26,6 +26,9 @@
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.SessionManager;
|
||||
import com.sk89q.worldguard.session.WorldPlayerTuple;
|
||||
import com.sk89q.worldguard.session.handler.*;
|
||||
import com.sk89q.worldguard.session.handler.Handler.Factory;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -64,7 +67,7 @@ public class BukkitSessionManager implements SessionManager, Runnable, Listener
|
||||
.build(new CacheLoader<WorldPlayerTuple, Boolean>() {
|
||||
@Override
|
||||
public Boolean load(WorldPlayerTuple tuple) throws Exception {
|
||||
return plugin.getGlobalRegionManager().hasBypass(tuple.player, tuple.world);
|
||||
return tuple.getPlayer().hasPermission("worldguard.region.bypass." + tuple.getWorld().getName());
|
||||
}
|
||||
});
|
||||
|
@ -33,6 +33,7 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -41,6 +42,8 @@
|
||||
*/
|
||||
public final class Materials {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Materials.class.getSimpleName());
|
||||
|
||||
private static final int MODIFIED_ON_RIGHT = 1;
|
||||
private static final int MODIFIED_ON_LEFT = 2;
|
||||
private static final int MODIFIES_BLOCKS = 4;
|
||||
@ -119,8 +122,20 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.PISTON, 0);
|
||||
MATERIAL_FLAGS.put(Material.PISTON_HEAD, 0);
|
||||
MATERIAL_FLAGS.put(Material.MOVING_PISTON, 0);
|
||||
MATERIAL_FLAGS.put(Material.YELLOW_FLOWER, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_ROSE, 0);
|
||||
MATERIAL_FLAGS.put(Material.DANDELION, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_ORCHID, 0);
|
||||
MATERIAL_FLAGS.put(Material.ALLIUM, 0);
|
||||
MATERIAL_FLAGS.put(Material.AZURE_BLUET, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_TULIP, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_TULIP, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_TULIP, 0);
|
||||
MATERIAL_FLAGS.put(Material.WHITE_TULIP, 0);
|
||||
MATERIAL_FLAGS.put(Material.OXEYE_DAISY, 0);
|
||||
MATERIAL_FLAGS.put(Material.SUNFLOWER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LILAC, 0);
|
||||
MATERIAL_FLAGS.put(Material.PEONY, 0);
|
||||
MATERIAL_FLAGS.put(Material.ROSE_BUSH, 0);
|
||||
MATERIAL_FLAGS.put(Material.POPPY, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_MUSHROOM, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_MUSHROOM, 0);
|
||||
MATERIAL_FLAGS.put(Material.GOLD_BLOCK, 0);
|
||||
@ -132,7 +147,7 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.OBSIDIAN, 0);
|
||||
MATERIAL_FLAGS.put(Material.TORCH, 0);
|
||||
MATERIAL_FLAGS.put(Material.FIRE, 0);
|
||||
MATERIAL_FLAGS.put(Material.MOB_SPAWNER, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SPAWNER, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.CHEST, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.REDSTONE_WIRE, 0);
|
||||
MATERIAL_FLAGS.put(Material.DIAMOND_ORE, 0);
|
||||
@ -141,29 +156,23 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.WHEAT, 0);
|
||||
MATERIAL_FLAGS.put(Material.FARMLAND, 0);
|
||||
MATERIAL_FLAGS.put(Material.FURNACE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BURNING_FURNACE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SIGN_POST, 0);
|
||||
MATERIAL_FLAGS.put(Material.WOODEN_DOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SIGN, 0);
|
||||
MATERIAL_FLAGS.put(Material.LADDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.RAIL, 0);
|
||||
MATERIAL_FLAGS.put(Material.COBBLESTONE_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.WALL_SIGN, 0);
|
||||
MATERIAL_FLAGS.put(Material.LEVER, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.STONE_PRESSURE_PLATE, 0);
|
||||
MATERIAL_FLAGS.put(Material.IRON_DOOR_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.WOOD_PLATE, 0);
|
||||
MATERIAL_FLAGS.put(Material.REDSTONE_ORE, 0);
|
||||
MATERIAL_FLAGS.put(Material.REDSTONE_WALL_TORCH, 0);
|
||||
MATERIAL_FLAGS.put(Material.REDSTONE_TORCH, 0);
|
||||
MATERIAL_FLAGS.put(Material.STONE_BUTTON, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SNOW, 0);
|
||||
MATERIAL_FLAGS.put(Material.ICE, 0);
|
||||
MATERIAL_FLAGS.put(Material.SNOW_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.CACTUS, 0);
|
||||
MATERIAL_FLAGS.put(Material.CLAY, 0);
|
||||
MATERIAL_FLAGS.put(Material.SUGAR_CANE, 0);
|
||||
MATERIAL_FLAGS.put(Material.JUKEBOX, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.OAK_FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PUMPKIN, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHERRACK, 0);
|
||||
MATERIAL_FLAGS.put(Material.SOUL_SAND, 0);
|
||||
@ -172,26 +181,43 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.JACK_O_LANTERN, 0);
|
||||
MATERIAL_FLAGS.put(Material.CAKE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.REPEATER, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.STAINED_GLASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.TRAP_DOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.MONSTER_EGGS, 0);
|
||||
MATERIAL_FLAGS.put(Material.SMOOTH_BRICK, 0);
|
||||
MATERIAL_FLAGS.put(Material.HUGE_MUSHROOM_1, 0);
|
||||
MATERIAL_FLAGS.put(Material.HUGE_MUSHROOM_2, 0);
|
||||
MATERIAL_FLAGS.put(Material.IRON_FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.THIN_GLASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.MELON_BLOCK, 0);
|
||||
// MATERIAL_FLAGS.put(Material.STAINED_GLASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.ACACIA_TRAPDOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BIRCH_TRAPDOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.DARK_OAK_TRAPDOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.JUNGLE_TRAPDOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.OAK_TRAPDOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SPRUCE_TRAPDOOR, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.INFESTED_STONE, 0);
|
||||
MATERIAL_FLAGS.put(Material.INFESTED_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.INFESTED_MOSSY_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.INFESTED_CRACKED_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.INFESTED_CHISELED_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.INFESTED_COBBLESTONE, 0);
|
||||
MATERIAL_FLAGS.put(Material.STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.MOSSY_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.CRACKED_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.CHISELED_STONE_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_MUSHROOM_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_MUSHROOM_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.IRON_BARS, 0);
|
||||
MATERIAL_FLAGS.put(Material.GLASS_PANE, 0);
|
||||
MATERIAL_FLAGS.put(Material.MELON, 0);
|
||||
MATERIAL_FLAGS.put(Material.PUMPKIN_STEM, 0);
|
||||
MATERIAL_FLAGS.put(Material.MELON_STEM, 0);
|
||||
MATERIAL_FLAGS.put(Material.VINE, 0);
|
||||
MATERIAL_FLAGS.put(Material.FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SPRUCE_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.ACACIA_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BIRCH_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.DARK_OAK_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.JUNGLE_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.OAK_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BRICK_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.MYCEL, 0);
|
||||
MATERIAL_FLAGS.put(Material.WATER_LILY, 0);
|
||||
MATERIAL_FLAGS.put(Material.MYCELIUM, 0);
|
||||
MATERIAL_FLAGS.put(Material.LILY_PAD, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_BRICK, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_BRICK_FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_BRICK_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_WARTS, 0);
|
||||
MATERIAL_FLAGS.put(Material.ENCHANTING_TABLE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BREWING_STAND, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.CAULDRON, MODIFIED_ON_RIGHT);
|
||||
@ -211,9 +237,6 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.BEACON, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.COBBLESTONE_WALL, 0);
|
||||
MATERIAL_FLAGS.put(Material.FLOWER_POT, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.CARROT, 0);
|
||||
MATERIAL_FLAGS.put(Material.POTATO, 0);
|
||||
MATERIAL_FLAGS.put(Material.WOOD_BUTTON, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.ANVIL, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.TRAPPED_CHEST, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.HEAVY_WEIGHTED_PRESSURE_PLATE, 0);
|
||||
@ -227,15 +250,17 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.QUARTZ_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.ACTIVATOR_RAIL, 0);
|
||||
MATERIAL_FLAGS.put(Material.DROPPER, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.STAINED_CLAY, 0);
|
||||
MATERIAL_FLAGS.put(Material.STAINED_GLASS_PANE, 0);
|
||||
// MATERIAL_FLAGS.put(Material.STAINED_CLAY, 0);
|
||||
// MATERIAL_FLAGS.put(Material.STAINED_GLASS_PANE, 0);
|
||||
MATERIAL_FLAGS.put(Material.ACACIA_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.DARK_OAK_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.HAY_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.HARD_CLAY, 0);
|
||||
// MATERIAL_FLAGS.put(Material.HARD_CLAY, 0);
|
||||
MATERIAL_FLAGS.put(Material.COAL_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.PACKED_ICE, 0);
|
||||
MATERIAL_FLAGS.put(Material.DOUBLE_PLANT, 0);
|
||||
MATERIAL_FLAGS.put(Material.TALL_GRASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.TALL_SEAGRASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.LARGE_FERN, 0);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.PRISMARINE, 0);
|
||||
MATERIAL_FLAGS.put(Material.SEA_LANTERN, 0);
|
||||
@ -243,11 +268,6 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.IRON_TRAPDOOR, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_SANDSTONE, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_SANDSTONE_STAIRS, 0);
|
||||
MATERIAL_FLAGS.put(Material.SPRUCE_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BIRCH_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.JUNGLE_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.DARK_OAK_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.ACACIA_FENCE_GATE, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.SPRUCE_FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BIRCH_FENCE, 0);
|
||||
MATERIAL_FLAGS.put(Material.JUNGLE_FENCE, 0);
|
||||
@ -280,12 +300,37 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.RED_NETHER_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.BONE_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.STRUCTURE_VOID, 0);
|
||||
for (Material m : shulkerBoxes) {
|
||||
MATERIAL_FLAGS.put(m, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
// 1.12
|
||||
MATERIAL_FLAGS.put(Material.CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLACK_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.CYAN_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.GRAY_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.GREEN_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_BLUE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_GRAY_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIME_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAGENTA_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PURPLE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.WHITE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLACK_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.CYAN_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.GRAY_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.GREEN_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_BLUE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_GRAY_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIME_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAGENTA_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.PURPLE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.WHITE_CONCRETE_POWDER, 0);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.WHITE_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_GLAZED_TERRACOTTA, 0);
|
||||
@ -344,7 +389,7 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.DIAMOND_HOE, MODIFIES_BLOCKS);
|
||||
MATERIAL_FLAGS.put(Material.GOLDEN_HOE, MODIFIES_BLOCKS);
|
||||
MATERIAL_FLAGS.put(Material.WHEAT_SEEDS, MODIFIES_BLOCKS);
|
||||
MATERIAL_FLAGS.put(Material.WHEAT, 0);
|
||||
// MATERIAL_FLAGS.put(Material.WHEAT_CROPS, 0); // Where is this?
|
||||
MATERIAL_FLAGS.put(Material.BREAD, 0);
|
||||
MATERIAL_FLAGS.put(Material.LEATHER_HELMET, 0);
|
||||
MATERIAL_FLAGS.put(Material.LEATHER_CHESTPLATE, 0);
|
||||
@ -371,7 +416,6 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.COOKED_PORKCHOP, 0);
|
||||
MATERIAL_FLAGS.put(Material.PAINTING, 0);
|
||||
MATERIAL_FLAGS.put(Material.GOLDEN_APPLE, 0);
|
||||
MATERIAL_FLAGS.put(Material.SIGN, 0);
|
||||
MATERIAL_FLAGS.put(Material.BUCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.WATER_BUCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.LAVA_BUCKET, 0);
|
||||
@ -383,7 +427,7 @@ public final class Materials {
|
||||
|
||||
MATERIAL_FLAGS.put(Material.LEATHER, 0);
|
||||
MATERIAL_FLAGS.put(Material.MILK_BUCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.BRICK, 0);
|
||||
MATERIAL_FLAGS.put(Material.BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.CLAY_BALL, 0);
|
||||
MATERIAL_FLAGS.put(Material.SUGAR_CANE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PAPER, 0);
|
||||
@ -412,27 +456,10 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.COCOA_BEANS, MODIFIES_BLOCKS);
|
||||
MATERIAL_FLAGS.put(Material.BONE, 0);
|
||||
MATERIAL_FLAGS.put(Material.SUGAR, 0);
|
||||
MATERIAL_FLAGS.put(Material.CAKE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLACK_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.CYAN_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.GRAY_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.GREEN_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_BLUE_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_GRAY_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.LIME_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.MAGENTA_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.PINK_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.PURPLE_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.RED_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.WHITE_BED, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.REPEATER, 0);
|
||||
MATERIAL_FLAGS.put(Material.COOKIE, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAP, 0);
|
||||
MATERIAL_FLAGS.put(Material.SHEARS, MODIFIES_BLOCKS);
|
||||
MATERIAL_FLAGS.put(Material.MELON, 0);
|
||||
MATERIAL_FLAGS.put(Material.MELON_SLICE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PUMPKIN_SEEDS, 0);
|
||||
MATERIAL_FLAGS.put(Material.MELON_SEEDS, 0);
|
||||
MATERIAL_FLAGS.put(Material.BEEF, 0);
|
||||
@ -444,25 +471,21 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.BLAZE_ROD, 0);
|
||||
MATERIAL_FLAGS.put(Material.GHAST_TEAR, 0);
|
||||
MATERIAL_FLAGS.put(Material.GOLD_NUGGET, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_WART_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_WART, 0);
|
||||
MATERIAL_FLAGS.put(Material.POTION, 0);
|
||||
MATERIAL_FLAGS.put(Material.GLASS_BOTTLE, 0);
|
||||
MATERIAL_FLAGS.put(Material.SPIDER_EYE, 0);
|
||||
MATERIAL_FLAGS.put(Material.FERMENTED_SPIDER_EYE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLAZE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAGMA_CREAM, 0);
|
||||
MATERIAL_FLAGS.put(Material.BREWING_STAND, 0);
|
||||
MATERIAL_FLAGS.put(Material.CAULDRON, 0);
|
||||
MATERIAL_FLAGS.put(Material.ENDER_EYE, 0);
|
||||
MATERIAL_FLAGS.put(Material.GLISTERING_MELON_SLICE, 0);
|
||||
MATERIAL_FLAGS.put(Material.MONSTER_EGG, 0);
|
||||
MATERIAL_FLAGS.put(Material.EXPERIENCE_BOTTLE, 0);
|
||||
MATERIAL_FLAGS.put(Material.FIRE_CHARGE, 0);
|
||||
MATERIAL_FLAGS.put(Material.WRITABLE_BOOK, 0);
|
||||
MATERIAL_FLAGS.put(Material.WRITTEN_BOOK, 0);
|
||||
MATERIAL_FLAGS.put(Material.EMERALD, 0);
|
||||
MATERIAL_FLAGS.put(Material.ITEM_FRAME, 0);
|
||||
MATERIAL_FLAGS.put(Material.FLOWER_POT, 0);
|
||||
MATERIAL_FLAGS.put(Material.CARROT, 0);
|
||||
MATERIAL_FLAGS.put(Material.POTATO, 0);
|
||||
MATERIAL_FLAGS.put(Material.BAKED_POTATO, 0);
|
||||
@ -487,7 +510,6 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.FIREWORK_ROCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.FIREWORK_STAR, 0);
|
||||
MATERIAL_FLAGS.put(Material.ENCHANTED_BOOK, 0);
|
||||
MATERIAL_FLAGS.put(Material.COMPARATOR, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHER_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.QUARTZ, 0);
|
||||
MATERIAL_FLAGS.put(Material.TNT_MINECART, 0);
|
||||
@ -540,9 +562,14 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.MUSIC_DISC_WAIT, 0);
|
||||
MATERIAL_FLAGS.put(Material.MUSIC_DISC_WARD, 0);
|
||||
|
||||
// Fake tags
|
||||
for (Material m : shulkerBoxes) {
|
||||
MATERIAL_FLAGS.put(m, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
|
||||
// Generated via tag
|
||||
for (Material door : Tag.DOORS.getValues()) {
|
||||
MATERIAL_FLAGS.put(door, 0);
|
||||
MATERIAL_FLAGS.put(door, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material boat : Tag.ITEMS_BOATS.getValues()) {
|
||||
MATERIAL_FLAGS.put(boat, 0);
|
||||
@ -574,6 +601,26 @@ public final class Materials {
|
||||
for (Material wool : Tag.WOOL.getValues()) {
|
||||
MATERIAL_FLAGS.put(wool, 0);
|
||||
}
|
||||
for (Material plate : Tag.WOODEN_PRESSURE_PLATES.getValues()) {
|
||||
MATERIAL_FLAGS.put(plate, 0);
|
||||
}
|
||||
for (Material button : Tag.BUTTONS.getValues()) {
|
||||
MATERIAL_FLAGS.put(button, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
|
||||
// Check for missing items/blocks
|
||||
for (Material material : Material.values()) {
|
||||
// Add spawn eggs
|
||||
if (isSpawnEgg(material)) {
|
||||
MATERIAL_FLAGS.put(material, 0);
|
||||
} else if (isBed(material)) {
|
||||
MATERIAL_FLAGS.put(material, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
if (!MATERIAL_FLAGS.containsKey(material)) {
|
||||
logger.fine("Missing item definition for " + material.getKey().toString());
|
||||
MATERIAL_FLAGS.put(material, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//DAMAGE_EFFECTS.add(PotionEffectType.ABSORPTION);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.BLINDNESS);
|
||||
@ -766,6 +813,88 @@ public static boolean isInventoryBlock(Material material) {
|
||||
|| shulkerBoxes.contains(material);
|
||||
}
|
||||
|
||||
public static boolean isSpawnEgg(Material material) {
|
||||
switch(material) {
|
||||
case SPIDER_SPAWN_EGG:
|
||||
case BAT_SPAWN_EGG:
|
||||
case BLAZE_SPAWN_EGG:
|
||||
case CAVE_SPIDER_SPAWN_EGG:
|
||||
case CHICKEN_SPAWN_EGG:
|
||||
case COD_SPAWN_EGG:
|
||||
case COW_SPAWN_EGG:
|
||||
case CREEPER_SPAWN_EGG:
|
||||
case DOLPHIN_SPAWN_EGG:
|
||||
case DONKEY_SPAWN_EGG:
|
||||
case DROWNED_SPAWN_EGG:
|
||||
case ELDER_GUARDIAN_SPAWN_EGG:
|
||||
case ENDERMAN_SPAWN_EGG:
|
||||
case ENDERMITE_SPAWN_EGG:
|
||||
case EVOKER_SPAWN_EGG:
|
||||
case GHAST_SPAWN_EGG:
|
||||
case GUARDIAN_SPAWN_EGG:
|
||||
case HORSE_SPAWN_EGG:
|
||||
case HUSK_SPAWN_EGG:
|
||||
case LLAMA_SPAWN_EGG:
|
||||
case MAGMA_CUBE_SPAWN_EGG:
|
||||
case MOOSHROOM_SPAWN_EGG:
|
||||
case MULE_SPAWN_EGG:
|
||||
case OCELOT_SPAWN_EGG:
|
||||
case PARROT_SPAWN_EGG:
|
||||
case PHANTOM_SPAWN_EGG:
|
||||
case PIG_SPAWN_EGG:
|
||||
case POLAR_BEAR_SPAWN_EGG:
|
||||
case PUFFERFISH_SPAWN_EGG:
|
||||
case RABBIT_SPAWN_EGG:
|
||||
case SALMON_SPAWN_EGG:
|
||||
case SHEEP_SPAWN_EGG:
|
||||
case SHULKER_SPAWN_EGG:
|
||||
case SILVERFISH_SPAWN_EGG:
|
||||
case SKELETON_HORSE_SPAWN_EGG:
|
||||
case SKELETON_SPAWN_EGG:
|
||||
case SLIME_SPAWN_EGG:
|
||||
case SQUID_SPAWN_EGG:
|
||||
case STRAY_SPAWN_EGG:
|
||||
case TROPICAL_FISH_SPAWN_EGG:
|
||||
case TURTLE_SPAWN_EGG:
|
||||
case VEX_SPAWN_EGG:
|
||||
case VILLAGER_SPAWN_EGG:
|
||||
case VINDICATOR_SPAWN_EGG:
|
||||
case WITCH_SPAWN_EGG:
|
||||
case WITHER_SKELETON_SPAWN_EGG:
|
||||
case WOLF_SPAWN_EGG:
|
||||
case ZOMBIE_HORSE_SPAWN_EGG:
|
||||
case ZOMBIE_PIGMAN_SPAWN_EGG:
|
||||
case ZOMBIE_SPAWN_EGG:
|
||||
case ZOMBIE_VILLAGER_SPAWN_EGG:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBed(Material material) {
|
||||
switch (material) {
|
||||
case BLACK_BED:
|
||||
case BLUE_BED:
|
||||
case BROWN_BED:
|
||||
case CYAN_BED:
|
||||
case GRAY_BED:
|
||||
case GREEN_BED:
|
||||
case LIGHT_BLUE_BED:
|
||||
case LIGHT_GRAY_BED:
|
||||
case LIME_BED:
|
||||
case MAGENTA_BED:
|
||||
case ORANGE_BED:
|
||||
case PINK_BED:
|
||||
case PURPLE_BED:
|
||||
case RED_BED:
|
||||
case WHITE_BED:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the given material is affected by
|
||||
* {@link Flags#USE}.
|
||||
|
@ -19,9 +19,11 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.util.report;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.report.DataReport;
|
||||
@ -39,10 +41,11 @@ public ConfigReport(WorldGuardPlugin plugin) {
|
||||
|
||||
List<World> worlds = Bukkit.getServer().getWorlds();
|
||||
|
||||
append("Configuration", new ShallowObjectReport("Configuration", plugin.getGlobalStateManager()));
|
||||
append("Configuration", new ShallowObjectReport("Configuration", WorldGuard.getInstance().getPlatform().getGlobalStateManager()));
|
||||
|
||||
for (World world : worlds) {
|
||||
BukkitWorldConfiguration config = plugin.getGlobalStateManager().get(world);
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
|
||||
WorldConfiguration config = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(weWorld);
|
||||
|
||||
DataReport report = new DataReport("World: " + world.getName());
|
||||
report.append("UUID", world.getUID());
|
||||
@ -58,7 +61,7 @@ public ConfigReport(WorldGuardPlugin plugin) {
|
||||
report.append("Blacklist", "<Disabled>");
|
||||
}
|
||||
|
||||
RegionManager regions = plugin.getRegionContainer().get(world);
|
||||
RegionManager regions = WorldGuard.getInstance().getPlatform().getRegionContainer().get(weWorld);
|
||||
if (regions != null) {
|
||||
DataReport section = new DataReport("Regions");
|
||||
section.append("Region Count", regions.size());
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.util.report;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.util.report.DataReport;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
@ -35,7 +34,7 @@ public ServerReport() {
|
||||
append("Server Name", server.getServerName());
|
||||
append("Bukkit Version", server.getBukkitVersion());
|
||||
append("Implementation", server.getVersion());
|
||||
append("Player Count", "%d/%d", BukkitUtil.getOnlinePlayers().size(), server.getMaxPlayers());
|
||||
append("Player Count", "%d/%d", Bukkit.getOnlinePlayers().size(), server.getMaxPlayers());
|
||||
|
||||
append("Server Class Source", server.getClass().getProtectionDomain().getCodeSource().getLocation());
|
||||
|
||||
|
@ -24,18 +24,11 @@
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitRegionContainer;
|
||||
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.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
|
||||
/**
|
||||
* This is the legacy class for accessing region data.
|
||||
@ -45,96 +38,13 @@
|
||||
@Deprecated
|
||||
public class GlobalRegionManager {
|
||||
|
||||
private final BukkitRegionContainer container;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param container the container
|
||||
*/
|
||||
public GlobalRegionManager(BukkitRegionContainer container) {
|
||||
public GlobalRegionManager(RegionContainer container) {
|
||||
checkNotNull(container);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region manager for a world if one exists.
|
||||
*
|
||||
* <p>This method may return {@code null} if region data for the given
|
||||
* world has not been loaded, has failed to load, or support for regions
|
||||
* has been disabled.</p>
|
||||
*
|
||||
* @param world the world
|
||||
* @return a region manager, or {@code null} if one is not available
|
||||
*/
|
||||
@Nullable
|
||||
public RegionManager get(World world) {
|
||||
return container.get(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an immutable list of loaded {@link RegionManager}s.
|
||||
*
|
||||
* @return a list of managers
|
||||
*/
|
||||
public List<RegionManager> getLoaded() {
|
||||
return Collections.unmodifiableList(container.getLoaded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query.
|
||||
*
|
||||
* @return a new query
|
||||
*/
|
||||
private RegionQuery createQuery() {
|
||||
return container.createQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the given player has region protection bypass permission.
|
||||
*
|
||||
* @param player the player
|
||||
* @param world the world
|
||||
* @return true if a bypass is permitted
|
||||
* @deprecated use {@link BukkitRegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasBypass(LocalPlayer player, World world) {
|
||||
return player.hasPermission("worldguard.region.bypass." + world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the player can build (place, use, destroy blocks and
|
||||
* entities) at the given position, considering only the build flag
|
||||
* and the region's members.
|
||||
*
|
||||
* <p>This method is not an absolute test as to whether WorldGuard
|
||||
* would allow or block an event because this method doesn't
|
||||
* consider flags (i.e. chest-access flags when concerning a chest) or
|
||||
* other modules in WorldGuard (i.e chest protection).</p>
|
||||
*
|
||||
* @param player the player
|
||||
* @param location the location
|
||||
* @return true if a bypass is permitted
|
||||
* @deprecated use {@link BukkitRegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canBuild(LocalPlayer player, Location location) {
|
||||
return hasBypass(player, (World) location.getExtent()) || createQuery().testState(location, player, Flags.BUILD);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the player can place blocks at the given position.
|
||||
*
|
||||
* @param player the player
|
||||
* @param location the location
|
||||
* @return true if permitted
|
||||
* @deprecated the construct flag is being removed
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canConstruct(LocalPlayer player, Location location) {
|
||||
return canBuild(player, location);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,31 +53,11 @@ public boolean canConstruct(LocalPlayer player, Location location) {
|
||||
* @param flag the flag
|
||||
* @param location the location
|
||||
* @return true if set to true
|
||||
* @deprecated use {@link BukkitRegionContainer#createQuery()}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean allows(StateFlag flag, Location location) {
|
||||
return allows(flag, location, null);
|
||||
return StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(location, (RegionAssociable) null, flag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the value of a state flag at a location, using the player as the
|
||||
* relevant actor.
|
||||
*
|
||||
* @param flag the flag
|
||||
* @param location the location
|
||||
* @param player the actor
|
||||
* @return true if set to true
|
||||
* @deprecated use {@link BukkitRegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean allows(StateFlag flag, Location location, @Nullable LocalPlayer player) {
|
||||
if (player == null) {
|
||||
return StateFlag.test(createQuery().queryState(location, (RegionAssociable) null, flag));
|
||||
} else {
|
||||
return StateFlag.test(createQuery().queryState(location, player, flag));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,3 +2,4 @@ name: WorldGuard
|
||||
main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
|
||||
version: "${project.internalVersion}"
|
||||
softdepend: [WorldEdit, CommandBook]
|
||||
api-version: 1.13
|
||||
|
@ -20,17 +20,27 @@
|
||||
package com.sk89q.worldguard;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@org.junit.Ignore
|
||||
public class TestPlayer extends LocalPlayer {
|
||||
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
private final String name;
|
||||
private final Set<String> groups = new HashSet<String>();
|
||||
private final Set<String> groups = new HashSet<>();
|
||||
|
||||
public TestPlayer(String name) {
|
||||
this.name = name;
|
||||
@ -55,11 +65,6 @@ public boolean hasGroup(String group) {
|
||||
return groups.contains(group.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String msg) {
|
||||
System.out.println("TestPlayer{" + this.name + "} kicked!");
|
||||
@ -70,11 +75,96 @@ public void ban(String msg) {
|
||||
System.out.println("TestPlayer{" + this.name + "} banned!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(double health) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFoodLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(double foodLevel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSaturation() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(double saturation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherType getPlayerWeather() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerWeather(WeatherType weather) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerWeather() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerTimeRelative() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTimeOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerTime(long time, boolean relative) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerTime() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
System.out.println("-> TestPlayer{" + this.name + "}: " + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
@ -84,4 +174,51 @@ public String[] getGroups() {
|
||||
public boolean hasPermission(String perm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseItemStack getItemInHand(HandSide handSide) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(BaseItemStack itemStack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseEntity getState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroup;
|
||||
@ -56,8 +57,7 @@ public abstract class RegionEntryExitTest {
|
||||
TestPlayer builderPlayer;
|
||||
|
||||
protected FlagRegistry getFlagRegistry() {
|
||||
FlagRegistry registry = new SimpleFlagRegistry();
|
||||
return registry;
|
||||
return WorldGuard.getInstance().getFlagRegistry();
|
||||
}
|
||||
|
||||
protected abstract RegionManager createRegionManager() throws Exception;
|
||||
|
@ -23,6 +23,7 @@
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
@ -61,9 +62,7 @@ public abstract class RegionOverlapTest {
|
||||
TestPlayer player2;
|
||||
|
||||
protected FlagRegistry getFlagRegistry() {
|
||||
FlagRegistry registry = new SimpleFlagRegistry();
|
||||
registry.registerAll(Flags.getDefaultFlags());
|
||||
return registry;
|
||||
return WorldGuard.getInstance().getFlagRegistry();
|
||||
}
|
||||
|
||||
protected abstract RegionManager createRegionManager() throws Exception;
|
||||
|
@ -23,6 +23,7 @@
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
@ -59,9 +60,7 @@ public abstract class RegionPriorityTest {
|
||||
TestPlayer player2;
|
||||
|
||||
protected FlagRegistry getFlagRegistry() {
|
||||
FlagRegistry registry = new SimpleFlagRegistry();
|
||||
registry.registerAll(Flags.getDefaultFlags());
|
||||
return registry;
|
||||
return WorldGuard.getInstance().getFlagRegistry();
|
||||
}
|
||||
|
||||
protected abstract RegionManager createRegionManager() throws Exception;
|
||||
|
Loading…
Reference in New Issue
Block a user