blob: 0b670b94773142253fe9b95eef7d0bf259c2983f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
package com.redstoner.misc;
import com.redstoner.coremods.moduleLoader.ModuleLoader;
import com.redstoner.exceptions.MissingVersionException;
import com.redstoner.modules.Module;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.InputStream;
import java.io.InputStreamReader;
public class ModuleInfo {
private String simpleName;
private String displayName;
private String category;
private String description;
private String version;
private String warning;
public ModuleInfo(InputStream descriptor, Module module) {
try {
InputStreamReader reader = new InputStreamReader(descriptor);
FileConfiguration config = YamlConfiguration.loadConfiguration(reader);
displayName = config.getString("displayName");
category = config.getString("category");
description = config.getString("description");
} catch (Exception e) {
warning = "Descriptor file could not be loaded, using the class's name.";
}
simpleName = module.getClass().getSimpleName();
if (displayName == null)
displayName = simpleName;
if (category == null)
category = "Other";
try {
version = VersionHelper.getVersion(module.getClass());
} catch (MissingVersionException e) {}
}
public String getDisplayName() {
return displayName;
}
public String getWarning() {
return warning;
}
public String getModuleInfoHover() {
return "&8&o" + getSimpleName() + "\n"
+ "&r&e" + (getVersion() == null ? "&cVersion Missing" : getVersion())
+ "&r&9" + (ModuleLoader.hasCategories() ? "\n" + getCategory() : "")
+ "&r&7" + (getDescription() == null ? "" : "\n\n" + getDescription());
}
public String getSimpleName() {
return simpleName;
}
public String getVersion() {
return version;
}
public String getCategory() {
return category;
}
public String getDescription() {
return description;
}
}
|