mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-24 00:51:37 +01:00
Add some comments to LegacyItemDbProvider
This commit is contained in:
parent
17d5545804
commit
0afa00779c
@ -13,11 +13,22 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class LegacyItemDbProvider extends ItemDbProvider {
|
public class LegacyItemDbProvider extends ItemDbProvider {
|
||||||
|
// Maps all item names to legacy IDs
|
||||||
private final transient Map<String, Integer> items = new HashMap<>();
|
private final transient Map<String, Integer> items = new HashMap<>();
|
||||||
|
|
||||||
|
// Maps item data to all known names for an item
|
||||||
private final transient Map<ItemData, List<String>> names = new HashMap<>();
|
private final transient Map<ItemData, List<String>> names = new HashMap<>();
|
||||||
|
|
||||||
|
// Maps item data to the primary name for an item
|
||||||
private final transient Map<ItemData, String> primaryNames = new HashMap<>();
|
private final transient Map<ItemData, String> primaryNames = new HashMap<>();
|
||||||
|
|
||||||
|
// Maps legacy IDs to item data
|
||||||
private final transient Map<Integer, LegacyItemData> legacyIds = new HashMap<>();
|
private final transient Map<Integer, LegacyItemData> legacyIds = new HashMap<>();
|
||||||
|
|
||||||
|
// Maps names for an item to durability/meta values
|
||||||
private final transient Map<String, Short> durabilities = new HashMap<>();
|
private final transient Map<String, Short> durabilities = new HashMap<>();
|
||||||
|
|
||||||
|
// Maps names for an item to NBT data
|
||||||
private final transient Map<String, String> nbtData = new HashMap<>();
|
private final transient Map<String, String> nbtData = new HashMap<>();
|
||||||
|
|
||||||
private final transient Pattern splitPattern = Pattern.compile("((.*)[:+',;.](\\d+))");
|
private final transient Pattern splitPattern = Pattern.compile("((.*)[:+',;.](\\d+))");
|
||||||
@ -35,6 +46,7 @@ public class LegacyItemDbProvider extends ItemDbProvider {
|
|||||||
String itemname;
|
String itemname;
|
||||||
short metaData = 0;
|
short metaData = 0;
|
||||||
|
|
||||||
|
// If the user provided id:metadata, split it
|
||||||
Matcher parts = splitPattern.matcher(name);
|
Matcher parts = splitPattern.matcher(name);
|
||||||
if (parts.matches()) {
|
if (parts.matches()) {
|
||||||
itemname = parts.group(2);
|
itemname = parts.group(2);
|
||||||
@ -43,6 +55,7 @@ public class LegacyItemDbProvider extends ItemDbProvider {
|
|||||||
itemname = name;
|
itemname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check whether the user provided an ID
|
||||||
if (isInt(itemname)) {
|
if (isInt(itemname)) {
|
||||||
itemid = Integer.parseInt(itemname);
|
itemid = Integer.parseInt(itemname);
|
||||||
} else if (isInt(name)) {
|
} else if (isInt(name)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user