mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Update the Bukkit adapter to the Spigot API Preview
This commit is contained in:
parent
724661d903
commit
ca06a05117
@ -10,8 +10,8 @@ repositories {
|
||||
dependencies {
|
||||
compile project(':worldedit-core')
|
||||
compile 'com.sk89q:dummypermscompat:1.8'
|
||||
// compile 'org.bukkit:bukkit:18w15a-R0.1-SNAPSHOT' // zzz
|
||||
compile 'org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT' // zzz
|
||||
compile 'org.bukkit:bukkit:1.13-pre5-R0.1-SNAPSHOT' // zzz
|
||||
// compile 'org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT' // zzz
|
||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class CommandRegistration {
|
||||
|
||||
public boolean unregisterCommands() {
|
||||
CommandMap commandMap = getCommandMap();
|
||||
List<String> toRemove = new ArrayList<String>();
|
||||
List<String> toRemove = new ArrayList<>();
|
||||
Map<String, org.bukkit.command.Command> knownCommands = ReflectionUtil.getField(commandMap, "knownCommands");
|
||||
Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
|
||||
if (knownCommands == null || aliases == null) {
|
||||
|
@ -50,7 +50,7 @@ public class CommandsManagerRegistration extends CommandRegistration {
|
||||
}
|
||||
|
||||
public boolean registerAll(List<Command> registered) {
|
||||
List<CommandInfo> toRegister = new ArrayList<CommandInfo>();
|
||||
List<CommandInfo> toRegister = new ArrayList<>();
|
||||
for (Command command : registered) {
|
||||
List<String> permissions = null;
|
||||
Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]);
|
||||
@ -59,7 +59,7 @@ public class CommandsManagerRegistration extends CommandRegistration {
|
||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||
permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||
} else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) {
|
||||
permissions = new ArrayList<String>();
|
||||
permissions = new ArrayList<>();
|
||||
for (Method m : childMethods.values()) {
|
||||
if (m.isAnnotationPresent(CommandPermissions.class)) {
|
||||
permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value()));
|
||||
|
@ -52,11 +52,11 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
userGroups = new HashMap<String, Set<String>>();
|
||||
userPermissionsCache = new HashMap<String, Set<String>>();
|
||||
defaultPermissionsCache = new HashSet<String>();
|
||||
userGroups = new HashMap<>();
|
||||
userPermissionsCache = new HashMap<>();
|
||||
defaultPermissionsCache = new HashSet<>();
|
||||
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||
|
||||
List<String> groupKeys = config.getStringList("permissions.groups", null);
|
||||
|
||||
@ -66,7 +66,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
config.getStringList("permissions.groups." + key + ".permissions", null);
|
||||
|
||||
if (!permissions.isEmpty()) {
|
||||
Set<String> groupPerms = new HashSet<String>(permissions);
|
||||
Set<String> groupPerms = new HashSet<>(permissions);
|
||||
userGroupPermissions.put(key, groupPerms);
|
||||
|
||||
if (key.equals("default")) {
|
||||
@ -80,7 +80,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
if (userKeys != null) {
|
||||
for (String key : userKeys) {
|
||||
Set<String> permsCache = new HashSet<String>();
|
||||
Set<String> permsCache = new HashSet<>();
|
||||
|
||||
List<String> permissions =
|
||||
config.getStringList("permissions.users." + key + ".permissions", null);
|
||||
@ -103,7 +103,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||
userGroups.put(key.toLowerCase(), new HashSet<String>(groups));
|
||||
userGroups.put(key.toLowerCase(), new HashSet<>(groups));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,13 +114,13 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
if (perms == null) {
|
||||
return new String[0];
|
||||
}
|
||||
List<String> groupNames = new ArrayList<String>();
|
||||
List<String> groupNames = new ArrayList<>();
|
||||
for (PermissionAttachmentInfo permAttach : perms.getEffectivePermissions()) {
|
||||
String perm = permAttach.getPermission();
|
||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
|
||||
continue;
|
||||
}
|
||||
groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length()));
|
||||
groupNames.add(perm.substring(GROUP_PREFIX.length()));
|
||||
}
|
||||
return groupNames.toArray(new String[groupNames.size()]);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public Map<String, Set<String>> loadGroupPermissions() {
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||
|
||||
BufferedReader buff = null;
|
||||
|
||||
@ -93,7 +93,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
if (parts.length > 1) {
|
||||
String[] perms = parts[1].split(",");
|
||||
|
||||
Set<String> groupPerms = new HashSet<String>(Arrays.asList(perms));
|
||||
Set<String> groupPerms = new HashSet<>(Arrays.asList(perms));
|
||||
userGroupPermissions.put(key, groupPerms);
|
||||
}
|
||||
}
|
||||
@ -113,9 +113,9 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
userGroups = new HashMap<String, Set<String>>();
|
||||
userPermissionsCache = new HashMap<String, Set<String>>();
|
||||
defaultPermissionsCache = new HashSet<String>();
|
||||
userGroups = new HashMap<>();
|
||||
userPermissionsCache = new HashMap<>();
|
||||
defaultPermissionsCache = new HashSet<>();
|
||||
|
||||
Map<String, Set<String>> userGroupPermissions = loadGroupPermissions();
|
||||
|
||||
@ -131,7 +131,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
Set<String> permsCache = new HashSet<String>();
|
||||
Set<String> permsCache = new HashSet<>();
|
||||
|
||||
line = line.trim();
|
||||
|
||||
@ -160,7 +160,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||
userGroups.put(key.toLowerCase(), new HashSet<String>(Arrays.asList(groups)));
|
||||
userGroups.put(key.toLowerCase(), new HashSet<>(Arrays.asList(groups)));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -50,7 +50,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
Plugin plugin = pluginManager.getPlugin("Permissions");
|
||||
|
||||
// Check if plugin is loaded and has Permissions interface
|
||||
if (plugin == null || !(plugin instanceof Permissions)) {
|
||||
if (!(plugin instanceof Permissions)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -22,19 +22,19 @@ package com.sk89q.wepif;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public interface PermissionsProvider {
|
||||
public boolean hasPermission(String name, String permission);
|
||||
boolean hasPermission(String name, String permission);
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission);
|
||||
boolean hasPermission(String worldName, String name, String permission);
|
||||
|
||||
public boolean inGroup(String player, String group);
|
||||
boolean inGroup(String player, String group);
|
||||
|
||||
public String[] getGroups(String player);
|
||||
String[] getGroups(String player);
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission);
|
||||
boolean hasPermission(OfflinePlayer player, String permission);
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission);
|
||||
boolean hasPermission(String worldName, OfflinePlayer player, String permission);
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group);
|
||||
boolean inGroup(OfflinePlayer player, String group);
|
||||
|
||||
public String[] getGroups(OfflinePlayer player);
|
||||
String[] getGroups(OfflinePlayer player);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.wepif;
|
||||
|
||||
public interface PermissionsResolver extends PermissionsProvider {
|
||||
public void load();
|
||||
void load();
|
||||
|
||||
public String getDetectionMessage();
|
||||
String getDetectionMessage();
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
private PermissionsResolver permissionResolver;
|
||||
private YAMLProcessor config;
|
||||
private Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<Class<? extends PermissionsResolver>>();
|
||||
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||
@ -213,7 +213,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
if (!keys.contains("resolvers")) {
|
||||
//List<String> resolverKeys = config.getKeys("resolvers");
|
||||
List<String> resolvers = new ArrayList<String>();
|
||||
List<String> resolvers = new ArrayList<>();
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
resolvers.add(clazz.getSimpleName());
|
||||
}
|
||||
@ -221,7 +221,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
config.setProperty("resolvers.enabled", resolvers);
|
||||
isUpdated = true;
|
||||
} else {
|
||||
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<String>());
|
||||
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<>());
|
||||
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
|
||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
|
||||
String nextName = i.next();
|
||||
|
@ -138,7 +138,7 @@ class BukkitEntityType implements EntityType {
|
||||
|
||||
@Override
|
||||
public boolean isTagged() {
|
||||
return entity instanceof LivingEntity && ((LivingEntity) entity).getCustomName() != null;
|
||||
return entity instanceof LivingEntity && entity.getCustomName() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +69,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
||||
? player.getInventory().getItemInMainHand()
|
||||
: player.getInventory().getItemInOffHand();
|
||||
return BukkitUtil.toBlock(itemStack);
|
||||
return new BaseBlock(BukkitUtil.toBlock(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,7 +79,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void giveItem(BaseItemStack itemStack) {
|
||||
player.getInventory().addItem(new ItemStack(itemStack.getLegacyId(), itemStack.getAmount()));
|
||||
player.getInventory().addItem(BukkitUtil.toItemStack(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -223,7 +223,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
// CopyOnWrite list for the list of players, but the Bukkit
|
||||
// specification doesn't require thread safety (though the
|
||||
// spec is extremely incomplete)
|
||||
return Bukkit.getServer().getPlayerExact(name) != null;
|
||||
return Bukkit.getServer().getPlayer(uuid) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
@ -78,8 +79,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bukkitItem.getTypeId() != blockState.getBlockType().getLegacyId()) {
|
||||
// TODO Fix when bukkit gets not awful
|
||||
if (!bukkitItem.getType().getKey().toString().equals(blockState.getBlockType().getId())) {
|
||||
// Type id doesn't fit
|
||||
continue;
|
||||
}
|
||||
@ -111,6 +111,9 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
if (blockState.getBlockType() == BlockTypes.AIR) {
|
||||
throw new IllegalArgumentException("Can't store air block");
|
||||
}
|
||||
if (!blockState.getBlockType().hasItemType()) {
|
||||
throw new IllegalArgumentException("This block cannot be stored");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
@ -129,8 +132,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bukkitItem.getTypeId() != blockState.getBlockType().getLegacyId()) {
|
||||
// TODO Fix when bukkit gets not terrible
|
||||
if (!bukkitItem.getType().getKey().toString().equals(blockState.getBlockType().getId())) {
|
||||
// Type id doesn't fit
|
||||
continue;
|
||||
}
|
||||
@ -156,7 +158,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
}
|
||||
|
||||
if (freeSlot > -1) {
|
||||
items[freeSlot] = new ItemStack(blockState.getBlockType().getLegacyId(), amount); // TODO Ditto
|
||||
items[freeSlot] = new ItemStack(BukkitUtil.toItemStack(new BaseItemStack(blockState.getBlockType().getItemType(), amount)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
|
||||
@Override
|
||||
public void registerCommands(Dispatcher dispatcher) {
|
||||
List<CommandInfo> toRegister = new ArrayList<CommandInfo>();
|
||||
List<CommandInfo> toRegister = new ArrayList<>();
|
||||
BukkitCommandInspector inspector = new BukkitCommandInspector(plugin, dispatcher);
|
||||
|
||||
for (CommandMapping command : dispatcher.getCommands()) {
|
||||
@ -159,7 +159,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
|
||||
@Override
|
||||
public Map<Capability, Preference> getCapabilities() {
|
||||
Map<Capability, Preference> capabilities = new EnumMap<Capability, Preference>(Capability.class);
|
||||
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);
|
||||
capabilities.put(Capability.CONFIGURATION, Preference.NORMAL);
|
||||
capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL);
|
||||
capabilities.put(Capability.GAME_HOOKS, Preference.PREFERRED);
|
||||
@ -175,7 +175,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
|
||||
@Override
|
||||
public Collection<Actor> getConnectedUsers() {
|
||||
List<Actor> users = new ArrayList<Actor>();
|
||||
List<Actor> users = new ArrayList<>();
|
||||
for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
users.add(new BukkitPlayer(plugin, player));
|
||||
}
|
||||
|
@ -22,17 +22,19 @@ package com.sk89q.worldedit.bukkit;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -121,17 +123,28 @@ public final class BukkitUtil {
|
||||
return ((BukkitWorld) world).getWorld();
|
||||
}
|
||||
|
||||
public static BaseBlock toBlock(ItemStack itemStack) throws WorldEditException {
|
||||
ItemType itemType = LegacyMapper.getInstance().getItemFromLegacy(itemStack.getTypeId(), itemStack.getData().getData());
|
||||
if (itemType.hasBlockType()) {
|
||||
return new BaseBlock(itemType.getBlockType().getDefaultState());
|
||||
public static BlockState toBlock(BlockData blockData) {
|
||||
return null; // TODO BLOCKING
|
||||
}
|
||||
|
||||
public static BlockData toBlock(BlockStateHolder block) {
|
||||
return Bukkit.createBlockData(block.toString()); // TODO BLOCKING
|
||||
}
|
||||
|
||||
public static BlockState toBlock(ItemStack itemStack) throws WorldEditException {
|
||||
if (itemStack.getType().isBlock()) {
|
||||
return toBlock(itemStack.getType().createBlockData());
|
||||
} else {
|
||||
return new BaseBlock(BlockTypes.AIR.getDefaultState());
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseItemStack toBaseItemStack(ItemStack itemStack) {
|
||||
ItemType itemType = LegacyMapper.getInstance().getItemFromLegacy(itemStack.getTypeId(), itemStack.getData().getData());
|
||||
return new BaseItemStack(itemType, itemStack.getAmount());
|
||||
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
||||
}
|
||||
|
||||
public static ItemStack toItemStack(BaseItemStack item) {
|
||||
BlockData blockData = Bukkit.createBlockData(item.getType().getId());
|
||||
return new ItemStack(blockData.getMaterial(), item.getAmount());
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
@ -38,7 +37,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
@ -49,7 +48,6 @@ import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@ -286,15 +284,16 @@ public class BukkitWorld extends AbstractWorld {
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
||||
World world = getWorld();
|
||||
TreeType bukkitType = toBukkitTreeType(type);
|
||||
return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType);
|
||||
// return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType,
|
||||
// new EditSessionBlockChangeDelegate(editSession));
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItem(Vector pt, BaseItemStack item) {
|
||||
World world = getWorld();
|
||||
ItemStack bukkitItem = new ItemStack(item.getLegacyId(), item.getAmount()); // TODO Add data.
|
||||
world.dropItemNaturally(BukkitUtil.toLocation(world, pt), bukkitItem);
|
||||
world.dropItemNaturally(BukkitUtil.toLocation(world, pt), BukkitUtil.toItemStack(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -359,7 +358,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getBlock(Vector position) {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return LegacyMapper.getInstance().getBlockFromLegacy(bukkitBlock.getTypeId(), bukkitBlock.getData());
|
||||
return BukkitUtil.toBlock(bukkitBlock.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -369,11 +368,8 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
||||
} else {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(block.toImmutableState());
|
||||
if (datas == null) {
|
||||
throw new WorldEditException("Unknown block"){}; // TODO Remove.
|
||||
}
|
||||
return bukkitBlock.setTypeIdAndData(datas[0], (byte) datas[1], notifyAndLight);
|
||||
bukkitBlock.setData(BukkitUtil.toBlock(block), notifyAndLight);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,17 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
|
||||
/**
|
||||
* Proxy class to catch calls to set blocks.
|
||||
*/
|
||||
public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
public class EditSessionBlockChangeDelegate {//implements BlockChangeDelegate {
|
||||
|
||||
private EditSession editSession;
|
||||
|
||||
@ -37,48 +32,50 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
this.editSession = editSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRawTypeId(int x, int y, int z, int typeId) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), LegacyMapper.getInstance().getBlockFromLegacy(typeId));
|
||||
} catch (MaxChangedBlocksException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// TODO This needs a fix in Spigot itself
|
||||
|
||||
@Override
|
||||
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), LegacyMapper.getInstance().getBlockFromLegacy(typeId, data));
|
||||
} catch (MaxChangedBlocksException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTypeId(int x, int y, int z, int typeId) {
|
||||
return setRawTypeId(x, y, z, typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
return setRawTypeIdAndData(x, y, z, typeId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTypeId(int x, int y, int z) {
|
||||
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(editSession.getBlock(new Vector(x, y, z)));
|
||||
return datas[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return editSession.getWorld().getMaxY() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(int x, int y, int z) {
|
||||
return editSession.getBlock(new Vector(x, y, z)).getBlockType() == BlockTypes.AIR;
|
||||
}
|
||||
// @Override
|
||||
// public boolean setRawTypeId(int x, int y, int z, int typeId) {
|
||||
// try {
|
||||
// return editSession.setBlock(new Vector(x, y, z), LegacyMapper.getInstance().getBlockFromLegacy(typeId));
|
||||
// } catch (MaxChangedBlocksException ex) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
// try {
|
||||
// return editSession.setBlock(new Vector(x, y, z), LegacyMapper.getInstance().getBlockFromLegacy(typeId, data));
|
||||
// } catch (MaxChangedBlocksException ex) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean setTypeId(int x, int y, int z, int typeId) {
|
||||
// return setRawTypeId(x, y, z, typeId);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
// return setRawTypeIdAndData(x, y, z, typeId, data);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getTypeId(int x, int y, int z) {
|
||||
// int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(editSession.getBlock(new Vector(x, y, z)));
|
||||
// return datas[0];
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getHeight() {
|
||||
// return editSession.getWorld().getMaxY() + 1;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isEmpty(int x, int y, int z) {
|
||||
// return editSession.getBlock(new Vector(x, y, z)).getBlockType() == BlockTypes.AIR;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -25,16 +25,11 @@ import com.google.common.base.Joiner;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.CylinderSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
@ -42,12 +37,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -73,7 +62,7 @@ import javax.annotation.Nullable;
|
||||
public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
|
||||
private static final Logger log = Logger.getLogger(WorldEditPlugin.class.getCanonicalName());
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
|
||||
private static WorldEditPlugin INSTANCE;
|
||||
|
||||
private BukkitImplAdapter bukkitAdapter;
|
||||
@ -346,64 +335,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
return WorldEdit.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region selection for the player.
|
||||
*
|
||||
* @param player aplayer
|
||||
* @return the selection or null if there was none
|
||||
*/
|
||||
public Selection getSelection(Player player) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wrapPlayer(player));
|
||||
RegionSelector selector = session.getRegionSelector(BukkitUtil.getWorld(player.getWorld()));
|
||||
|
||||
try {
|
||||
Region region = selector.getRegion();
|
||||
World world = BukkitAdapter.asBukkitWorld(session.getSelectionWorld()).getWorld();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
return new CuboidSelection(world, selector, (CuboidRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
|
||||
} else if (region instanceof CylinderRegion) {
|
||||
return new CylinderSelection(world, selector, (CylinderRegion) region);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the region selection for a player.
|
||||
*
|
||||
* @param player the player
|
||||
* @param selection a selection
|
||||
*/
|
||||
public void setSelection(Player player, Selection selection) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException("Null selection not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wrapPlayer(player));
|
||||
RegionSelector sel = selection.getRegionSelector();
|
||||
session.setRegionSelector(BukkitUtil.getWorld(player.getWorld()), sel);
|
||||
session.dispatchCUISelection(wrapPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of this plugin.
|
||||
*
|
||||
|
@ -38,7 +38,7 @@ import java.util.logging.Logger;
|
||||
public class BukkitImplLoader {
|
||||
|
||||
private static final Logger log = Logger.getLogger(BukkitImplLoader.class.getCanonicalName());
|
||||
private final List<String> adapterCandidates = new ArrayList<String>();
|
||||
private final List<String> adapterCandidates = new ArrayList<>();
|
||||
private String customCandidate;
|
||||
|
||||
private static final String SEARCH_PACKAGE = "com.sk89q.worldedit.bukkit.adapter.impl";
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit 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.worldedit.bukkit.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.PermissiveSelectorLimits;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
|
||||
protected CuboidRegion cuboid;
|
||||
|
||||
public CuboidSelection(World world, Location pt1, Location pt2) {
|
||||
this(world, BukkitUtil.toVector(pt1), BukkitUtil.toVector(pt2));
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
// Validate input
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
// Create new selector
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector(BukkitUtil.getWorld(world));
|
||||
|
||||
// set up selector
|
||||
sel.selectPrimary(pt1, PermissiveSelectorLimits.getInstance());
|
||||
sel.selectSecondary(pt2, PermissiveSelectorLimits.getInstance());
|
||||
|
||||
// set up CuboidSelection
|
||||
cuboid = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(cuboid);
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit 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.worldedit.bukkit.selections;
|
||||
|
||||
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
/**
|
||||
* A selection representing a {@link CylinderRegion}
|
||||
*/
|
||||
public class CylinderSelection extends RegionSelection {
|
||||
|
||||
private CylinderRegion cylRegion;
|
||||
|
||||
public CylinderSelection(World world, RegionSelector selector, CylinderRegion region) {
|
||||
super(world, selector, region);
|
||||
this.cylRegion = region;
|
||||
}
|
||||
|
||||
public CylinderSelection(World world, BlockVector2D center, BlockVector2D radius, int minY, int maxY) {
|
||||
super(world);
|
||||
com.sk89q.worldedit.world.World lWorld = BukkitUtil.getWorld(world);
|
||||
|
||||
// Validate input
|
||||
minY = Math.min(Math.max(0, minY), world.getMaxHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getMaxHeight());
|
||||
|
||||
// Create and set up new selector
|
||||
CylinderRegionSelector sel = new CylinderRegionSelector(lWorld, center, radius, minY, maxY);
|
||||
|
||||
// set up selection
|
||||
cylRegion = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(cylRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the center vector of the cylinder
|
||||
*
|
||||
* @return the center
|
||||
*/
|
||||
public BlockVector2D getCenter() {
|
||||
return cylRegion.getCenter().toVector2D().toBlockVector2D();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the radius vector of the cylinder
|
||||
*
|
||||
* @return the radius
|
||||
*/
|
||||
public BlockVector2D getRadius() {
|
||||
return cylRegion.getRadius().toBlockVector2D();
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit 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.worldedit.bukkit.selections;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.*;
|
||||
|
||||
public class Polygonal2DSelection extends RegionSelection {
|
||||
|
||||
protected Polygonal2DRegion poly2d;
|
||||
|
||||
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
|
||||
super(world, sel, region);
|
||||
this.poly2d = region;
|
||||
}
|
||||
|
||||
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
super(world);
|
||||
com.sk89q.worldedit.world.World lWorld = BukkitUtil.getWorld(world);
|
||||
|
||||
// Validate input
|
||||
minY = Math.min(Math.max(0, minY), world.getMaxHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getMaxHeight());
|
||||
|
||||
// Create and set up new selector
|
||||
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(lWorld, points, minY, maxY);
|
||||
|
||||
// set up CuboidSelection
|
||||
poly2d = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(poly2d);
|
||||
}
|
||||
|
||||
public List<BlockVector2D> getNativePoints() {
|
||||
return Collections.unmodifiableList(poly2d.getPoints());
|
||||
}
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit 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.worldedit.bukkit.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import static com.sk89q.worldedit.bukkit.BukkitUtil.toLocation;
|
||||
import static com.sk89q.worldedit.bukkit.BukkitUtil.toVector;
|
||||
|
||||
public abstract class RegionSelection implements Selection {
|
||||
|
||||
private World world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionSelector getRegionSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getMinimumPoint() {
|
||||
return toLocation(world, region.getMinimumPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getNativeMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getMaximumPoint() {
|
||||
return toLocation(world, region.getMaximumPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getNativeMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return region.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return region.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength() {
|
||||
return region.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Location position) {
|
||||
if (!position.getWorld().equals(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return region.contains(toVector(position));
|
||||
}
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit 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.worldedit.bukkit.selections;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An abstraction of WorldEdit regions, which do not use Bukkit objects.
|
||||
*/
|
||||
public interface Selection {
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Location getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Vector getNativeMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Location getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Vector getNativeMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the region selector. This is for internal use.
|
||||
*
|
||||
* @return the region selector
|
||||
*/
|
||||
public RegionSelector getRegionSelector();
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return the world, which may be null
|
||||
*/
|
||||
@Nullable
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
*
|
||||
* @return number of blocks
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
/**
|
||||
* Get X-size.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
/**
|
||||
* Get Y-size.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
* Get Z-size.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point,
|
||||
*
|
||||
* @param position a vector
|
||||
* @return true if it is contained
|
||||
*/
|
||||
public boolean contains(Location position);
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
||||
private boolean op;
|
||||
private UUID randomUuid = UUID.randomUUID();
|
||||
|
||||
private final Map<String, Boolean> assignedPermissions = new HashMap<String, Boolean>();
|
||||
private final Map<String, Boolean> assignedPermissions = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
@ -101,7 +101,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
Set<PermissionAttachmentInfo> ret = new HashSet<PermissionAttachmentInfo>();
|
||||
Set<PermissionAttachmentInfo> ret = new HashSet<>();
|
||||
for (Map.Entry<String, Boolean> entry : assignedPermissions.entrySet()) {
|
||||
ret.add(new PermissionAttachmentInfo(this, entry.getKey(), null, entry.getValue()));
|
||||
}
|
||||
@ -141,11 +141,6 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean b) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
|
@ -27,10 +27,9 @@ public class BukkitWorldTest {
|
||||
|
||||
@Test
|
||||
public void testTreeTypeMapping() {
|
||||
// TODO
|
||||
// for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||
// Assert.assertFalse("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type) == null);
|
||||
// }
|
||||
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||
// Assert.assertNotNull("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type)); // TODO
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -30,6 +31,7 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sun.xml.internal.bind.v2.TODO;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -188,11 +190,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @return a pumpkin pattern
|
||||
*/
|
||||
public static Pattern getPumpkinPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// TODO pattern.add(new BlockPattern(new BaseBlock(BlockTypes.CARVED_PUMPKIN, i)), 100);
|
||||
}
|
||||
return pattern;
|
||||
return new BlockPattern(BlockTypes.CARVED_PUMPKIN.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ public class ForgeWorldEdit {
|
||||
|
||||
public static Logger logger;
|
||||
public static final String MOD_ID = "worldedit";
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
|
||||
|
||||
private ForgePermissionsProvider provider;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.spongepowered.api.network.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class CUIChannelHandler implements RawDataListener {
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
|
||||
|
||||
private static ChannelBinding.RawDataChannel channel;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user