Development Assistance The method getTargetBlock(HashSet<Byte>, int) is ambiguous for the type Player

Discussion in 'Plugin Help/Development/Requests' started by inittab, Feb 18, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    inittab

    Trying to get the block a player is looking at when they left click and running into an ambiguous error and not exactly sure why any help is appreciated.

    [​IMG]

    pom.xml:
    <repositories>
    <repository>
    <id>bukkit-repo</id>
    <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
    </repository>
    </repositories>
    <dependencies>
    <dependency>
    <groupId>org.bukkit</groupId>
    <artifactId>bukkit</artifactId>
    <version>1.8-R0.1-SNAPSHOT</version>
    <type>jar</type>
    <scope>provided</scope>
    </dependency>
    </dependencies>

    code:
    public void onPlayerInteract(PlayerInteractEvent event)
    {
    if (event.hasItem())
    {
    if (event.getItem().getType() == Material.STRING)
    getLogger().info("User is holding string");
    {
    if ((event.getAction() == Action.LEFT_CLICK_AIR) || event.getAction() == Action.LEFT_CLICK_BLOCK)
    {
    getLogger().info("User left clicked");
    LivingEntity player = event.getPlayer();
    if (player.hasPermission("funthings.lightning")) {
    Block block = player.getTargetBlock(null, 100);
    World world = player.getWorld();
    world.strikeLightning(block.getLocation());
    }

    }
    }
    }
    }
     
    Last edited: Feb 18, 2015
  2. Offline

    1Rogue

    Cast your null value:

    Code:java
    1. Block block = player.getTargetBlock((Set<Material>) null, 100);
     
  3. Offline

    inittab

    Thanks, that worked, getting the following when actually left clicking though, any ideas?
    I've tried both Player player and LivingEntity player both do the same thing.

    [06:35:53 ERROR]: Could not pass event PlayerInteractEvent to FunThings v0.002
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:226) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:193) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.PlayerInteractManager.a(PlayerInteractManager.java:107) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:588) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.PacketPlayInBlockDig.a(SourceFile:40) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.PacketPlayInBlockDig.a(SourceFile:10) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_31]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_31]
    at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:685) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigot-1.8.jar:git-Spigot-952179b-2f50138]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_31]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.entity.LivingEntity.getTargetBlock(Ljava/util/Set;I)Lorg/bukkit/block/Block;
    at com.inittab.funthings.FunThings.onPlayerInteract(FunThings.java:63) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-1.8.jar:git-Spigot-952179b-2f50138]
    ... 17 more
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    1Rogue

    Try casting to the other value then.
     
  6. Offline

    inittab

    Got everything working now. Thanks guys.
     
Thread Status:
Not open for further replies.

Share This Page