From ca06a05117c2e7acbc3393371c9e6ed20df50f05 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 12 Jul 2018 22:23:03 +1000 Subject: [PATCH] Update the Bukkit adapter to the Spigot API Preview --- worldedit-bukkit/build.gradle | 4 +- .../bukkit/util/CommandRegistration.java | 2 +- .../util/CommandsManagerRegistration.java | 4 +- .../ConfigurationPermissionsResolver.java | 14 +-- .../com/sk89q/wepif/DinnerPermsResolver.java | 4 +- .../wepif/FlatFilePermissionsResolver.java | 14 +-- .../sk89q/wepif/NijiPermissionsResolver.java | 2 +- .../com/sk89q/wepif/PermissionsProvider.java | 16 +-- .../com/sk89q/wepif/PermissionsResolver.java | 4 +- .../wepif/PermissionsResolverManager.java | 6 +- .../worldedit/bukkit/BukkitEntityType.java | 2 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 6 +- .../bukkit/BukkitPlayerBlockBag.java | 12 +- .../bukkit/BukkitServerInterface.java | 6 +- .../sk89q/worldedit/bukkit/BukkitUtil.java | 35 ++++-- .../sk89q/worldedit/bukkit/BukkitWorld.java | 22 ++-- .../EditSessionBlockChangeDelegate.java | 93 +++++++------- .../worldedit/bukkit/WorldEditPlugin.java | 71 +---------- .../bukkit/adapter/BukkitImplLoader.java | 2 +- .../bukkit/selections/CuboidSelection.java | 70 ----------- .../bukkit/selections/CylinderSelection.java | 79 ------------ .../selections/Polygonal2DSelection.java | 62 --------- .../bukkit/selections/RegionSelection.java | 118 ------------------ .../bukkit/selections/Selection.java | 113 ----------------- .../sk89q/wepif/TestOfflinePermissible.java | 9 +- .../worldedit/bukkit/BukkitWorldTest.java | 7 +- .../generator/GardenPatchGenerator.java | 8 +- .../sk89q/worldedit/forge/ForgeWorldEdit.java | 2 +- .../worldedit/sponge/CUIChannelHandler.java | 2 +- 29 files changed, 139 insertions(+), 650 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CuboidSelection.java delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CylinderSelection.java delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Selection.java diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index d396a2574..1d6e5428e 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -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' } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index 2417b2ced..e7df6832c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -82,7 +82,7 @@ public class CommandRegistration { public boolean unregisterCommands() { CommandMap commandMap = getCommandMap(); - List toRemove = new ArrayList(); + List toRemove = new ArrayList<>(); Map knownCommands = ReflectionUtil.getField(commandMap, "knownCommands"); Set aliases = ReflectionUtil.getField(commandMap, "aliases"); if (knownCommands == null || aliases == null) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java index 175c51c6d..5f8bfbc8c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java @@ -50,7 +50,7 @@ public class CommandsManagerRegistration extends CommandRegistration { } public boolean registerAll(List registered) { - List toRegister = new ArrayList(); + List toRegister = new ArrayList<>(); for (Command command : registered) { List 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(); + permissions = new ArrayList<>(); for (Method m : childMethods.values()) { if (m.isAnnotationPresent(CommandPermissions.class)) { permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value())); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java index 75beabdf2..b309265d6 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java @@ -52,11 +52,11 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { @Override public void load() { - userGroups = new HashMap>(); - userPermissionsCache = new HashMap>(); - defaultPermissionsCache = new HashSet(); + userGroups = new HashMap<>(); + userPermissionsCache = new HashMap<>(); + defaultPermissionsCache = new HashSet<>(); - Map> userGroupPermissions = new HashMap>(); + Map> userGroupPermissions = new HashMap<>(); List 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 groupPerms = new HashSet(permissions); + Set 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 permsCache = new HashSet(); + Set permsCache = new HashSet<>(); List 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(groups)); + userGroups.put(key.toLowerCase(), new HashSet<>(groups)); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java index 4e8199f9b..d5f9c7fc6 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java @@ -114,13 +114,13 @@ public class DinnerPermsResolver implements PermissionsResolver { if (perms == null) { return new String[0]; } - List groupNames = new ArrayList(); + List 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()]); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java index 704694c9f..3f2324596 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java @@ -67,7 +67,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } public Map> loadGroupPermissions() { - Map> userGroupPermissions = new HashMap>(); + Map> 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 groupPerms = new HashSet(Arrays.asList(perms)); + Set 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>(); - userPermissionsCache = new HashMap>(); - defaultPermissionsCache = new HashSet(); + userGroups = new HashMap<>(); + userPermissionsCache = new HashMap<>(); + defaultPermissionsCache = new HashSet<>(); Map> userGroupPermissions = loadGroupPermissions(); @@ -131,7 +131,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { String line; while ((line = buff.readLine()) != null) { - Set permsCache = new HashSet(); + Set 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(Arrays.asList(groups))); + userGroups.put(key.toLowerCase(), new HashSet<>(Arrays.asList(groups))); } } } catch (IOException e) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java index f3502d460..182a29faf 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java @@ -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; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsProvider.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsProvider.java index 2d9be46a3..8332a519b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsProvider.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsProvider.java @@ -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); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolver.java index 1423ede23..918c1bc23 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolver.java @@ -20,7 +20,7 @@ package com.sk89q.wepif; public interface PermissionsResolver extends PermissionsProvider { - public void load(); + void load(); - public String getDetectionMessage(); + String getDetectionMessage(); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index babc4a4cf..01f04546b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -86,7 +86,7 @@ public class PermissionsResolverManager implements PermissionsResolver { private PermissionsResolver permissionResolver; private YAMLProcessor config; private Logger logger = Logger.getLogger(getClass().getCanonicalName()); - private List> enabledResolvers = new ArrayList>(); + private List> enabledResolvers = new ArrayList<>(); @SuppressWarnings("unchecked") protected Class[] availableResolvers = new Class[] { @@ -213,7 +213,7 @@ public class PermissionsResolverManager implements PermissionsResolver { if (!keys.contains("resolvers")) { //List resolverKeys = config.getKeys("resolvers"); - List resolvers = new ArrayList(); + List 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 disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList()); + List disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<>()); List stagedEnabled = config.getStringList("resolvers.enabled", null); for (Iterator i = stagedEnabled.iterator(); i.hasNext();) { String nextName = i.next(); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java index 43d20b6b9..67ec4d2c8 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java @@ -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 diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 1b5b140d4..983e61770 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -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 diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java index 1fe40ef5b..05f3d4609 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java @@ -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; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index 8c125dc9b..e66fdaa40 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -117,7 +117,7 @@ public class BukkitServerInterface implements MultiUserPlatform { @Override public void registerCommands(Dispatcher dispatcher) { - List toRegister = new ArrayList(); + List 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 getCapabilities() { - Map capabilities = new EnumMap(Capability.class); + Map 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 getConnectedUsers() { - List users = new ArrayList(); + List users = new ArrayList<>(); for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) { users.add(new BukkitPlayer(plugin, player)); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java index 4cb965341..9f8f7a969 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java @@ -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()); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 955c1cf9e..4333cd7af 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -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; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java index df900feb5..9a9bfc219 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java @@ -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; +// } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 4910db731..0122352ae 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -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. * diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java index 1bb953421..40a94baf1 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java @@ -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 adapterCandidates = new ArrayList(); + private final List adapterCandidates = new ArrayList<>(); private String customCandidate; private static final String SEARCH_PACKAGE = "com.sk89q.worldedit.bukkit.adapter.impl"; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CuboidSelection.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CuboidSelection.java deleted file mode 100644 index 9f1783dde..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CuboidSelection.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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; - } -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CylinderSelection.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CylinderSelection.java deleted file mode 100644 index 2a5282146..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/CylinderSelection.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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(); - } - -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java deleted file mode 100644 index a7034a842..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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 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 getNativePoints() { - return Collections.unmodifiableList(poly2d.getPoints()); - } -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java deleted file mode 100644 index db705a8be..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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)); - } - -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Selection.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Selection.java deleted file mode 100644 index c3788affc..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/selections/Selection.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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); - -} diff --git a/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java b/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java index 81e41e9d7..a67351cd5 100644 --- a/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java +++ b/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java @@ -34,7 +34,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { private boolean op; private UUID randomUuid = UUID.randomUUID(); - private final Map assignedPermissions = new HashMap(); + private final Map assignedPermissions = new HashMap<>(); @Override public boolean isOp() { @@ -101,7 +101,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { @Override public Set getEffectivePermissions() { - Set ret = new HashSet(); + Set ret = new HashSet<>(); for (Map.Entry 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."); diff --git a/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java b/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java index 6ad440d8f..bc5f7f882 100644 --- a/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java +++ b/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java @@ -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 + } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java index 866fe6735..3abc89a32 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java @@ -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()); } /** diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java index ea0ded3ff..66b57ff78 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java @@ -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; diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CUIChannelHandler.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CUIChannelHandler.java index 1be22b0b0..863e48e9c 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CUIChannelHandler.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CUIChannelHandler.java @@ -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;