-
So I have the following struct: pub struct BlockBreakEvent<'mc>(
pub(crate) jni::JNIEnv<'mc>,
pub(crate) jni::objects::JObject<'mc>,
pub(crate) (),
pub(crate) Vec<jni::objects::JObject<'mc>>,
);
impl<'mc> BlockBreakEvent<'mc> {
// *snip*
pub fn set_cancelled(mut self, arg0: bool) -> Result<(), Box<dyn std::error::Error>> {
let val_0 = self
.0
.new_object("java/lang/Boolean", "(Z)V", &[arg0.into()])
.unwrap();
let _res = self.0.call_method(
&self.1,
"setCancelled",
"(Z)V",
&[jni::objects::JValueGen::from(&val_0)],
)?;
Ok(())
}
// *snip*
} It's bound to a Minecraft plugin and is based on SpigotMC's API. set_cancelled should call org.bukkit.event.block.BlockBreakEvent.setCancelled and pass a voolean into it. When this executes, though, I get this error:
Am I misreading the error? According to Spigot's docs this is exactly what the function takes as an argument list? What am I doing wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I was so tired that I failed to realize that I was looking at the wrong function and had made this post out of impulse. Oops... |
Beta Was this translation helpful? Give feedback.
-
No, that's not it; new_object requires the return type to void, I had that part right... |
Beta Was this translation helpful? Give feedback.
The
setCancelled
API takes a primitive boolean (Z) but you are currently passing ajava/lang/Boolean
object reference.Hopefully you can pass
&[arg0.into()]
tosetCancelled
without callingnew_object
.