we don't like integers we love strings
This commit is contained in:
@@ -12,7 +12,7 @@ import org.yaml.snakeyaml.Yaml;
|
||||
public class GiftMappingManager {
|
||||
private final JavaPlugin plugin;
|
||||
private final File mappingFile;
|
||||
private Map<Integer, String> giftMap = new HashMap<>();
|
||||
private Map<String, String> giftMap = new HashMap<>();
|
||||
|
||||
public GiftMappingManager(JavaPlugin plugin, String mappingUrl) {
|
||||
this.plugin = plugin;
|
||||
@@ -69,18 +69,18 @@ public class GiftMappingManager {
|
||||
|
||||
// downloadMapping is now handled by checkAndUpdateMapping
|
||||
|
||||
|
||||
public void loadMapping() {
|
||||
if (!mappingFile.exists()) return;
|
||||
try (InputStream input = new FileInputStream(mappingFile)) {
|
||||
Yaml yaml = new Yaml();
|
||||
Map<String, Object> data = yaml.load(input);
|
||||
Map<Object, Object> data = yaml.load(input);
|
||||
giftMap.clear();
|
||||
if (data != null) {
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
try {
|
||||
int id = Integer.parseInt(entry.getKey());
|
||||
giftMap.put(id, String.valueOf(entry.getValue()));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
for (Map.Entry<Object, Object> entry : data.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
String value = entry.getValue() != null ? entry.getValue().toString() : "";
|
||||
giftMap.put(key, value);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -89,6 +89,6 @@ public class GiftMappingManager {
|
||||
}
|
||||
|
||||
public String getGiftName(int id) {
|
||||
return giftMap.getOrDefault(id, "Unknown Gift");
|
||||
return giftMap.getOrDefault(String.valueOf(id), "Unknown Gift");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user