Improvements

This commit is contained in:
Chaoscaot
2023-03-06 19:01:03 +01:00
parent 0df001602e
commit ca249c8900
5 changed files with 47 additions and 43 deletions

View File

@ -8,14 +8,15 @@ use schemsearch_files::Schematic;
use schemsearch_lib::{search, SearchBehavior};
#[no_mangle]
#[allow(unused_variables)]
pub extern "system" fn Java_SchemSearch_search<'local>(mut env: JNIEnv<'local>,
class: JClass<'local>,
schematic_path: JString<'local>,
pattern_path: JString<'local>) -> jstring {
let schematic_path: String = env.get_string(&schematic_path).expect("Couldn't get java string!").into();
let pattern_path: String = env.get_string(&pattern_path).expect("Couldn't get java string!").into();
let schematic = Schematic::load(Path::new(&schematic_path));
let pattern = Schematic::load(Path::new(&pattern_path));
let schematic = Schematic::load(Path::new(&schematic_path)).unwrap();
let pattern = Schematic::load(Path::new(&pattern_path)).unwrap();
let matches = search(&schematic, &pattern, SearchBehavior {
ignore_block_data: true,
@ -27,8 +28,8 @@ pub extern "system" fn Java_SchemSearch_search<'local>(mut env: JNIEnv<'local>,
});
let mut result = String::new();
for (x, y, z) in matches {
result.push_str(&format!("{}, {}, {};", x, y, z));
for (x, y, z, p) in matches {
result.push_str(&format!("{}, {}, {}, {};", x, y, z, p));
}
result.remove(result.len() - 1);
let output = env.new_string(result).expect("Couldn't create java string!");