aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShayne Hartford <shaybox@shaybox.com>2023-01-05 15:31:25 -0500
committerGitHub <noreply@github.com>2023-01-05 14:31:25 -0600
commitfc88dabd954e09450bf7f155f36829f5678b6171 (patch)
tree1f1e12fa61cd773fba42d1233a46d72355f0f912
parentfd18cae4765fe498f007b7b8df4bc431f3a4e54e (diff)
downloadazalea-drasl-fc88dabd954e09450bf7f155f36829f5678b6171.tar.xz
Fix binary compilation (#53)
* Fix binary compilation * Unnecessary reference
-rwxr-xr-xazalea-language/src/lib.rs42
1 files changed, 3 insertions, 39 deletions
diff --git a/azalea-language/src/lib.rs b/azalea-language/src/lib.rs
index 4fd90c08..81c3cee2 100755
--- a/azalea-language/src/lib.rs
+++ b/azalea-language/src/lib.rs
@@ -1,46 +1,10 @@
//! Translate Minecraft strings from their id.
use once_cell::sync::Lazy;
-use std::io::Read;
-use std::path::Path;
-use std::{collections::HashMap, fs::File};
-// use tokio::fs::File;
+use std::collections::HashMap;
-// pub struct Language {
-// pub storage: HashMap<String, String>,
-// }
-
-// impl Language {
-// pub async fn load() -> Self {
-// // TODO: download from mojang's servers and cache somewhere
-
-// let mut storage = HashMap::new();
-// let mut file = File::open("en_us.json").unwrap();
-// let mut contents = String::new();
-// file.read_to_string(&mut contents).unwrap();
-// let en_us: HashMap<String, String> =
-// serde_json::from_str(&contents).unwrap(); Language { storage: en_us }
-// }
-
-// pub fn get(&self, key: &str) -> Option<&str> {
-// self.storage.get(key)
-// }
-// }
-
-// yeah i just decided to do this because otherwise we would have to have a
-// Language object that we passed around everywhere which is not convenient
-// The code above is kept in case I come up with a better solution
-
-pub static STORAGE: Lazy<HashMap<String, String>> = Lazy::new(|| {
- serde_json::from_str(&{
- let src_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/src/en_us.json"));
- let mut file = File::open(src_dir).unwrap();
- let mut contents = String::new();
- file.read_to_string(&mut contents).unwrap();
- contents
- })
- .unwrap()
-});
+pub static STORAGE: Lazy<HashMap<String, String>> =
+ Lazy::new(|| serde_json::from_str(include_str!("en_us.json")).unwrap());
pub fn get(key: &str) -> Option<&str> {
STORAGE.get(key).map(|s| s.as_str())