Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
c3450e89
Commit
c3450e89
authored
Aug 18, 2022
by
AnimeGitB
Browse files
Handbooks: use some sorted maps
parent
b3c80db4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/tools/Tools.java
View file @
c3450e89
...
...
@@ -21,8 +21,8 @@ import emu.grasscutter.data.excels.ItemData;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.utils.Language
;
import
emu.grasscutter.utils.Language.TextStrings
;
import
it.unimi.dsi.fastutil.ints.Int2IntMap
;
import
it.unimi.dsi.fastutil.ints.Int2Int
OpenHash
Map
;
import
it.unimi.dsi.fastutil.ints.Int2Int
Sorted
Map
;
import
it.unimi.dsi.fastutil.ints.Int2Int
RBTree
Map
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
static
emu
.
grasscutter
.
config
.
Configuration
.*;
...
...
@@ -33,11 +33,11 @@ public final class Tools {
final
Int2ObjectMap
<
TextStrings
>
textMaps
=
Language
.
getTextMapStrings
();
ResourceLoader
.
loadAll
();
final
Int2IntMap
avatarNames
=
new
Int2Int
OpenHash
Map
(
GameData
.
getAvatarDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getNameTextMapHash
())));
final
Int2IntMap
itemNames
=
new
Int2Int
OpenHash
Map
(
GameData
.
getItemDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getNameTextMapHash
())));
final
Int2IntMap
monsterNames
=
new
Int2Int
OpenHash
Map
(
GameData
.
getMonsterDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getNameTextMapHash
())));
final
Int2IntMap
mainQuestTitles
=
new
Int2Int
OpenHash
Map
(
GameData
.
getMainQuestDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getTitleTextMapHash
())));
// Int2IntMap questDescs = new Int2Int
OpenHash
Map(GameData.getQuestDataMap().int2ObjectEntrySet().stream().collect(Collectors.toMap(e -> (int) e.getIntKey(), e -> (int) e.getValue().getDescTextMapHash())));
final
Int2Int
Sorted
Map
avatarNames
=
new
Int2Int
RBTree
Map
(
GameData
.
getAvatarDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getNameTextMapHash
())));
final
Int2Int
Sorted
Map
itemNames
=
new
Int2Int
RBTree
Map
(
GameData
.
getItemDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getNameTextMapHash
())));
final
Int2Int
Sorted
Map
monsterNames
=
new
Int2Int
RBTree
Map
(
GameData
.
getMonsterDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getNameTextMapHash
())));
final
Int2Int
Sorted
Map
mainQuestTitles
=
new
Int2Int
RBTree
Map
(
GameData
.
getMainQuestDataMap
().
int2ObjectEntrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
(
int
)
e
.
getIntKey
(),
e
->
(
int
)
e
.
getValue
().
getTitleTextMapHash
())));
// Int2Int
Sorted
Map questDescs = new Int2Int
RBTree
Map(GameData.getQuestDataMap().int2ObjectEntrySet().stream().collect(Collectors.toMap(e -> (int) e.getIntKey(), e -> (int) e.getValue().getDescTextMapHash())));
// Preamble
final
List
<
StringBuilder
>
handbookBuilders
=
new
ArrayList
<>(
TextStrings
.
NUM_LANGUAGES
);
...
...
@@ -60,15 +60,15 @@ public final class Tools {
}
// Avatars, Items, Monsters
final
String
[]
handbookSections
=
{
"Avatars"
,
"Items"
,
"Monsters"
};
final
Int2IntMap
[]
handbookNames
=
{
avatarNames
,
itemNames
,
monsterNames
};
final
Int2Int
Sorted
Map
[]
handbookNames
=
{
avatarNames
,
itemNames
,
monsterNames
};
for
(
int
section
=
0
;
section
<
handbookSections
.
length
;
section
++)
{
final
Int2IntMap
h
=
handbookNames
[
section
];
final
var
h
=
handbookNames
[
section
];
final
String
s
=
"\n\n// "
+
handbookSections
[
section
]
+
"\n"
;
handbookBuilders
.
forEach
(
b
->
b
.
append
(
s
));
final
String
padId
=
"%"
+
Integer
.
toString
(
h
.
keySet
().
intStream
().
max
().
getAs
Int
()).
length
()
+
"s : "
;
h
.
keySet
().
intStream
().
sorted
().
forEach
(
id
->
{
final
String
padId
=
"%"
+
Integer
.
toString
(
h
.
keySet
().
last
Int
()).
length
()
+
"s : "
;
h
.
forEach
(
(
id
,
hash
)
->
{
final
String
sId
=
padId
.
formatted
(
id
);
final
TextStrings
t
=
textMaps
.
get
(
h
.
get
(
id
)
);
final
TextStrings
t
=
textMaps
.
get
(
(
int
)
hash
);
for
(
int
i
=
0
;
i
<
TextStrings
.
NUM_LANGUAGES
;
i
++)
handbookBuilders
.
get
(
i
).
append
(
sId
+
t
.
strings
[
i
]
+
"\n"
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment