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
a8293102
Commit
a8293102
authored
Jun 07, 2022
by
Melledy
Committed by
GitHub
Jun 07, 2022
Browse files
Merge branch 'development' into stable
parents
304b9cb8
ecf7a81a
Changes
410
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/
def
/ReliquarySetData.java
→
src/main/java/emu/grasscutter/data/
excels
/ReliquarySetData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"ReliquarySetExcelConfigData.json"
)
@ResourceType
(
name
=
"ReliquarySetExcelConfigData.json"
)
public
class
ReliquarySetData
extends
GameResource
{
public
class
ReliquarySetData
extends
GameResource
{
private
int
S
etId
;
private
int
s
etId
;
private
int
[]
S
etNeedNum
;
private
int
[]
s
etNeedNum
;
private
int
EquipAffixId
;
private
int
EquipAffixId
;
private
int
D
isableFilter
;
private
int
d
isableFilter
;
private
int
[]
C
ontainsList
;
private
int
[]
c
ontainsList
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
S
etId
;
return
s
etId
;
}
}
public
int
[]
getSetNeedNum
()
{
public
int
[]
getSetNeedNum
()
{
return
S
etNeedNum
;
return
s
etNeedNum
;
}
}
public
int
getEquipAffixId
()
{
public
int
getEquipAffixId
()
{
...
@@ -25,11 +25,11 @@ public class ReliquarySetData extends GameResource {
...
@@ -25,11 +25,11 @@ public class ReliquarySetData extends GameResource {
}
}
public
int
getDisableFilter
()
{
public
int
getDisableFilter
()
{
return
D
isableFilter
;
return
d
isableFilter
;
}
}
public
int
[]
getContainsList
()
{
public
int
[]
getContainsList
()
{
return
C
ontainsList
;
return
c
ontainsList
;
}
}
@Override
@Override
...
...
src/main/java/emu/grasscutter/data/
def
/RewardData.java
→
src/main/java/emu/grasscutter/data/
excels
/RewardData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.common.
RewardIte
mData
;
import
emu.grasscutter.data.common.
ItemPara
mData
;
@ResourceType
(
name
=
"RewardExcelConfigData.json"
)
@ResourceType
(
name
=
"RewardExcelConfigData.json"
)
public
class
RewardData
extends
GameResource
{
public
class
RewardData
extends
GameResource
{
public
int
R
ewardId
;
public
int
r
ewardId
;
public
List
<
RewardIte
mData
>
R
ewardItemList
;
public
List
<
ItemPara
mData
>
r
ewardItemList
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
R
ewardId
;
return
r
ewardId
;
}
}
public
List
<
RewardIte
mData
>
getRewardItemList
()
{
public
List
<
ItemPara
mData
>
getRewardItemList
()
{
return
R
ewardItemList
;
return
r
ewardItemList
;
}
}
@Override
@Override
public
void
onLoad
()
{
public
void
onLoad
()
{
rewardItemList
=
rewardItemList
.
stream
().
filter
(
i
->
i
.
getId
()
>
0
).
toList
();
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/RewardPreviewData.java
→
src/main/java/emu/grasscutter/data/
excels
/RewardPreviewData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -16,28 +16,28 @@ import emu.grasscutter.data.common.ItemParamStringData;
...
@@ -16,28 +16,28 @@ import emu.grasscutter.data.common.ItemParamStringData;
@ResourceType
(
name
=
"RewardPreviewExcelConfigData.json"
,
loadPriority
=
LoadPriority
.
HIGH
)
@ResourceType
(
name
=
"RewardPreviewExcelConfigData.json"
,
loadPriority
=
LoadPriority
.
HIGH
)
public
class
RewardPreviewData
extends
GameResource
{
public
class
RewardPreviewData
extends
GameResource
{
private
int
I
d
;
private
int
i
d
;
private
ItemParamStringData
[]
P
reviewItems
;
private
ItemParamStringData
[]
p
reviewItems
;
private
ItemParamData
[]
P
reviewItemsArray
;
private
ItemParamData
[]
p
reviewItemsArray
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
I
d
;
return
this
.
i
d
;
}
}
public
ItemParamData
[]
getPreviewItems
()
{
public
ItemParamData
[]
getPreviewItems
()
{
return
P
reviewItemsArray
;
return
p
reviewItemsArray
;
}
}
@Override
@Override
public
void
onLoad
()
{
public
void
onLoad
()
{
if
(
this
.
P
reviewItems
!=
null
&&
this
.
P
reviewItems
.
length
>
0
)
{
if
(
this
.
p
reviewItems
!=
null
&&
this
.
p
reviewItems
.
length
>
0
)
{
this
.
P
reviewItemsArray
=
Arrays
.
stream
(
this
.
P
reviewItems
)
this
.
p
reviewItemsArray
=
Arrays
.
stream
(
this
.
p
reviewItems
)
.
filter
(
d
->
d
.
getId
()
>
0
&&
d
.
getCount
()
!=
null
&&
!
d
.
getCount
().
isEmpty
())
.
filter
(
d
->
d
.
getId
()
>
0
&&
d
.
getCount
()
!=
null
&&
!
d
.
getCount
().
isEmpty
())
.
map
(
ItemParamStringData:
:
toItemParamData
)
.
map
(
ItemParamStringData:
:
toItemParamData
)
.
toArray
(
size
->
new
ItemParamData
[
size
]);
.
toArray
(
size
->
new
ItemParamData
[
size
]);
}
else
{
}
else
{
this
.
P
reviewItemsArray
=
new
ItemParamData
[
0
];
this
.
p
reviewItemsArray
=
new
ItemParamData
[
0
];
}
}
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/SceneData.java
→
src/main/java/emu/grasscutter/data/
excels
/SceneData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
...
@@ -8,22 +8,21 @@ import emu.grasscutter.game.props.SceneType;
...
@@ -8,22 +8,21 @@ import emu.grasscutter.game.props.SceneType;
@ResourceType
(
name
=
"SceneExcelConfigData.json"
)
@ResourceType
(
name
=
"SceneExcelConfigData.json"
)
public
class
SceneData
extends
GameResource
{
public
class
SceneData
extends
GameResource
{
private
int
I
d
;
private
int
i
d
;
private
SceneType
T
ype
;
private
SceneType
t
ype
;
private
String
S
criptData
;
private
String
s
criptData
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
I
d
;
return
this
.
i
d
;
}
}
public
SceneType
getSceneType
()
{
public
SceneType
getSceneType
()
{
return
T
ype
;
return
t
ype
;
}
}
public
String
getScriptData
()
{
public
String
getScriptData
()
{
return
S
criptData
;
return
s
criptData
;
}
}
@Override
@Override
...
...
src/main/java/emu/grasscutter/data/
def
/ShopGoodsData.java
→
src/main/java/emu/grasscutter/data/
excels
/ShopGoodsData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
...
@@ -9,34 +9,34 @@ import java.util.List;
...
@@ -9,34 +9,34 @@ import java.util.List;
@ResourceType
(
name
=
"ShopGoodsExcelConfigData.json"
)
@ResourceType
(
name
=
"ShopGoodsExcelConfigData.json"
)
public
class
ShopGoodsData
extends
GameResource
{
public
class
ShopGoodsData
extends
GameResource
{
private
int
G
oodsId
;
private
int
g
oodsId
;
private
int
S
hopType
;
private
int
s
hopType
;
private
int
I
temId
;
private
int
i
temId
;
private
int
I
temCount
;
private
int
i
temCount
;
private
int
C
ostScoin
;
private
int
c
ostScoin
;
private
int
C
ostHcoin
;
private
int
c
ostHcoin
;
private
int
C
ostMcoin
;
private
int
c
ostMcoin
;
private
List
<
ItemParamData
>
C
ostItems
;
private
List
<
ItemParamData
>
c
ostItems
;
private
int
M
inPlayerLevel
;
private
int
m
inPlayerLevel
;
private
int
M
axPlayerLevel
;
private
int
m
axPlayerLevel
;
private
int
B
uyLimit
;
private
int
b
uyLimit
;
private
int
S
ubTabId
;
private
int
s
ubTabId
;
private
String
R
efreshType
;
private
String
r
efreshType
;
private
transient
ShopInfo
.
ShopRefreshType
R
efreshTypeEnum
;
private
transient
ShopInfo
.
ShopRefreshType
r
efreshTypeEnum
;
private
int
R
efreshParam
;
private
int
r
efreshParam
;
@Override
@Override
public
void
onLoad
()
{
public
void
onLoad
()
{
if
(
this
.
R
efreshType
==
null
)
if
(
this
.
r
efreshType
==
null
)
this
.
R
efreshTypeEnum
=
ShopInfo
.
ShopRefreshType
.
NONE
;
this
.
r
efreshTypeEnum
=
ShopInfo
.
ShopRefreshType
.
NONE
;
else
{
else
{
this
.
R
efreshTypeEnum
=
switch
(
this
.
R
efreshType
)
{
this
.
r
efreshTypeEnum
=
switch
(
this
.
r
efreshType
)
{
case
"SHOP_REFRESH_DAILY"
->
ShopInfo
.
ShopRefreshType
.
SHOP_REFRESH_DAILY
;
case
"SHOP_REFRESH_DAILY"
->
ShopInfo
.
ShopRefreshType
.
SHOP_REFRESH_DAILY
;
case
"SHOP_REFRESH_WEEKLY"
->
ShopInfo
.
ShopRefreshType
.
SHOP_REFRESH_WEEKLY
;
case
"SHOP_REFRESH_WEEKLY"
->
ShopInfo
.
ShopRefreshType
.
SHOP_REFRESH_WEEKLY
;
case
"SHOP_REFRESH_MONTHLY"
->
ShopInfo
.
ShopRefreshType
.
SHOP_REFRESH_MONTHLY
;
case
"SHOP_REFRESH_MONTHLY"
->
ShopInfo
.
ShopRefreshType
.
SHOP_REFRESH_MONTHLY
;
...
@@ -51,58 +51,58 @@ public class ShopGoodsData extends GameResource {
...
@@ -51,58 +51,58 @@ public class ShopGoodsData extends GameResource {
}
}
public
int
getGoodsId
()
{
public
int
getGoodsId
()
{
return
G
oodsId
;
return
g
oodsId
;
}
}
public
int
getShopType
()
{
public
int
getShopType
()
{
return
S
hopType
;
return
s
hopType
;
}
}
public
int
getItemId
()
{
public
int
getItemId
()
{
return
I
temId
;
return
i
temId
;
}
}
public
int
getItemCount
()
{
public
int
getItemCount
()
{
return
I
temCount
;
return
i
temCount
;
}
}
public
int
getCostScoin
()
{
public
int
getCostScoin
()
{
return
C
ostScoin
;
return
c
ostScoin
;
}
}
public
int
getCostHcoin
()
{
public
int
getCostHcoin
()
{
return
C
ostHcoin
;
return
c
ostHcoin
;
}
}
public
int
getCostMcoin
()
{
public
int
getCostMcoin
()
{
return
C
ostMcoin
;
return
c
ostMcoin
;
}
}
public
List
<
ItemParamData
>
getCostItems
()
{
public
List
<
ItemParamData
>
getCostItems
()
{
return
C
ostItems
;
return
c
ostItems
;
}
}
public
int
getMinPlayerLevel
()
{
public
int
getMinPlayerLevel
()
{
return
M
inPlayerLevel
;
return
m
inPlayerLevel
;
}
}
public
int
getMaxPlayerLevel
()
{
public
int
getMaxPlayerLevel
()
{
return
M
axPlayerLevel
;
return
m
axPlayerLevel
;
}
}
public
int
getBuyLimit
()
{
public
int
getBuyLimit
()
{
return
B
uyLimit
;
return
b
uyLimit
;
}
}
public
int
getSubTabId
()
{
public
int
getSubTabId
()
{
return
S
ubTabId
;
return
s
ubTabId
;
}
}
public
ShopInfo
.
ShopRefreshType
getRefreshType
()
{
public
ShopInfo
.
ShopRefreshType
getRefreshType
()
{
return
R
efreshTypeEnum
;
return
r
efreshTypeEnum
;
}
}
public
int
getRefreshParam
()
{
public
int
getRefreshParam
()
{
return
R
efreshParam
;
return
r
efreshParam
;
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/TowerFloorData.java
→
src/main/java/emu/grasscutter/data/
excels
/TowerFloorData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
...
@@ -6,16 +6,16 @@ import emu.grasscutter.data.ResourceType;
...
@@ -6,16 +6,16 @@ import emu.grasscutter.data.ResourceType;
@ResourceType
(
name
=
"TowerFloorExcelConfigData.json"
)
@ResourceType
(
name
=
"TowerFloorExcelConfigData.json"
)
public
class
TowerFloorData
extends
GameResource
{
public
class
TowerFloorData
extends
GameResource
{
private
int
F
loorId
;
private
int
f
loorId
;
private
int
F
loorIndex
;
private
int
f
loorIndex
;
private
int
L
evelId
;
private
int
l
evel
Group
Id
;
private
int
O
verrideMonsterLevel
;
private
int
o
verrideMonsterLevel
;
private
int
T
eamNum
;
private
int
t
eamNum
;
private
int
F
loorLevelConfigId
;
private
int
f
loorLevelConfigId
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
F
loorId
;
return
this
.
f
loorId
;
}
}
@Override
@Override
...
@@ -24,50 +24,26 @@ public class TowerFloorData extends GameResource {
...
@@ -24,50 +24,26 @@ public class TowerFloorData extends GameResource {
}
}
public
int
getFloorId
()
{
public
int
getFloorId
()
{
return
FloorId
;
return
floorId
;
}
public
void
setFloorId
(
int
floorId
)
{
FloorId
=
floorId
;
}
}
public
int
getFloorIndex
()
{
public
int
getFloorIndex
()
{
return
FloorIndex
;
return
floorIndex
;
}
public
void
setFloorIndex
(
int
floorIndex
)
{
FloorIndex
=
floorIndex
;
}
public
int
getLevelId
()
{
return
LevelId
;
}
}
public
void
s
etLevel
Id
(
int
levelId
)
{
public
int
g
etLevel
GroupId
(
)
{
LevelId
=
levelId
;
return
level
Group
Id
;
}
}
public
int
getOverrideMonsterLevel
()
{
public
int
getOverrideMonsterLevel
()
{
return
OverrideMonsterLevel
;
return
overrideMonsterLevel
;
}
public
void
setOverrideMonsterLevel
(
int
overrideMonsterLevel
)
{
OverrideMonsterLevel
=
overrideMonsterLevel
;
}
}
public
int
getTeamNum
()
{
public
int
getTeamNum
()
{
return
TeamNum
;
return
teamNum
;
}
public
void
setTeamNum
(
int
teamNum
)
{
TeamNum
=
teamNum
;
}
}
public
int
getFloorLevelConfigId
()
{
public
int
getFloorLevelConfigId
()
{
return
FloorLevelConfigId
;
return
floorLevelConfigId
;
}
public
void
setFloorLevelConfigId
(
int
floorLevelConfigId
)
{
FloorLevelConfigId
=
floorLevelConfigId
;
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/TowerLevelData.java
→
src/main/java/emu/grasscutter/data/
excels
/TowerLevelData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"TowerLevelExcelConfigData.json"
)
@ResourceType
(
name
=
"TowerLevelExcelConfigData.json"
)
public
class
TowerLevelData
extends
GameResource
{
public
class
TowerLevelData
extends
GameResource
{
private
int
ID
;
private
int
levelId
;
private
int
L
evelI
d
;
private
int
l
evelI
ndex
;
private
int
L
evel
Index
;
private
int
l
evel
GroupId
;
private
int
D
ungeonId
;
private
int
d
ungeonId
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
ID
;
return
this
.
getLevelId
();
}
@Override
public
void
onLoad
()
{
super
.
onLoad
();
}
public
int
getID
()
{
return
ID
;
}
public
void
setID
(
int
ID
)
{
this
.
ID
=
ID
;
}
}
public
int
getLevelId
()
{
public
int
getLevelId
()
{
return
L
evelId
;
return
l
evelId
;
}
}
public
void
s
etLevel
Id
(
int
levelId
)
{
public
int
g
etLevel
GroupId
(
)
{
LevelId
=
levelId
;
return
level
Group
Id
;
}
}
public
int
getLevelIndex
()
{
public
int
getLevelIndex
()
{
return
LevelIndex
;
return
levelIndex
;
}
public
void
setLevelIndex
(
int
levelIndex
)
{
LevelIndex
=
levelIndex
;
}
}
public
int
getDungeonId
()
{
public
int
getDungeonId
()
{
return
DungeonId
;
return
dungeonId
;
}
public
void
setDungeonId
(
int
dungeonId
)
{
DungeonId
=
dungeonId
;
}
}
}
}
src/main/java/emu/grasscutter/data/excels/TowerScheduleData.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.data.excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
java.util.List
;
@ResourceType
(
name
=
"TowerScheduleExcelConfigData.json"
)
public
class
TowerScheduleData
extends
GameResource
{
private
int
scheduleId
;
private
List
<
Integer
>
entranceFloorId
;
private
List
<
ScheduleDetail
>
schedules
;
private
int
monthlyLevelConfigId
;
@Override
public
int
getId
()
{
return
scheduleId
;
}
@Override
public
void
onLoad
()
{
super
.
onLoad
();
this
.
schedules
=
this
.
schedules
.
stream
()
.
filter
(
item
->
item
.
getFloorList
().
size
()
>
0
)
.
toList
();
}
public
int
getScheduleId
()
{
return
scheduleId
;
}
public
List
<
Integer
>
getEntranceFloorId
()
{
return
entranceFloorId
;
}
public
List
<
ScheduleDetail
>
getSchedules
()
{
return
schedules
;
}
public
int
getMonthlyLevelConfigId
()
{
return
monthlyLevelConfigId
;
}
public
static
class
ScheduleDetail
{
private
List
<
Integer
>
floorList
;
public
List
<
Integer
>
getFloorList
()
{
return
floorList
;
}
}
}
src/main/java/emu/grasscutter/data/
def
/WeaponCurveData.java
→
src/main/java/emu/grasscutter/data/
excels
/WeaponCurveData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -10,23 +10,23 @@ import emu.grasscutter.data.common.CurveInfo;
...
@@ -10,23 +10,23 @@ import emu.grasscutter.data.common.CurveInfo;
@ResourceType
(
name
=
"WeaponCurveExcelConfigData.json"
)
@ResourceType
(
name
=
"WeaponCurveExcelConfigData.json"
)
public
class
WeaponCurveData
extends
GameResource
{
public
class
WeaponCurveData
extends
GameResource
{
private
int
L
evel
;
private
int
l
evel
;
private
CurveInfo
[]
C
urveInfos
;
private
CurveInfo
[]
c
urveInfos
;
private
Map
<
String
,
Float
>
curveInfos
;
private
Map
<
String
,
Float
>
curveInfos
Map
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
L
evel
;
return
l
evel
;
}
}
public
float
getMultByProp
(
String
fightProp
)
{
public
float
getMultByProp
(
String
fightProp
)
{
return
curveInfos
.
getOrDefault
(
fightProp
,
1
f
);
return
curveInfos
Map
.
getOrDefault
(
fightProp
,
1
f
);
}
}
@Override
@Override
public
void
onLoad
()
{
public
void
onLoad
()
{
this
.
curveInfos
=
new
HashMap
<>();
this
.
curveInfos
Map
=
new
HashMap
<>();
Stream
.
of
(
this
.
C
urveInfos
).
forEach
(
info
->
this
.
curveInfos
.
put
(
info
.
getType
(),
info
.
getValue
()));
Stream
.
of
(
this
.
c
urveInfos
).
forEach
(
info
->
this
.
curveInfos
Map
.
put
(
info
.
getType
(),
info
.
getValue
()));
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/WeaponLevelData.java
→
src/main/java/emu/grasscutter/data/
excels
/WeaponLevelData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"WeaponLevelExcelConfigData.json"
)
@ResourceType
(
name
=
"WeaponLevelExcelConfigData.json"
)
public
class
WeaponLevelData
extends
GameResource
{
public
class
WeaponLevelData
extends
GameResource
{
private
int
L
evel
;
private
int
l
evel
;
private
int
[]
R
equiredExps
;
private
int
[]
r
equiredExps
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
L
evel
;
return
this
.
l
evel
;
}
}
public
int
getLevel
()
{
public
int
getLevel
()
{
return
L
evel
;
return
l
evel
;
}
}
public
int
[]
getRequiredExps
()
{
public
int
[]
getRequiredExps
()
{
return
R
equiredExps
;
return
r
equiredExps
;
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/WeaponPromoteData.java
→
src/main/java/emu/grasscutter/data/
excels
/WeaponPromoteData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
...
@@ -9,45 +9,45 @@ import emu.grasscutter.data.common.ItemParamData;
...
@@ -9,45 +9,45 @@ import emu.grasscutter.data.common.ItemParamData;
@ResourceType
(
name
=
"WeaponPromoteExcelConfigData.json"
)
@ResourceType
(
name
=
"WeaponPromoteExcelConfigData.json"
)
public
class
WeaponPromoteData
extends
GameResource
{
public
class
WeaponPromoteData
extends
GameResource
{
private
int
W
eaponPromoteId
;
private
int
w
eaponPromoteId
;
private
int
P
romoteLevel
;
private
int
p
romoteLevel
;
private
ItemParamData
[]
C
ostItems
;
private
ItemParamData
[]
c
ostItems
;
private
int
C
oinCost
;
private
int
c
oinCost
;
private
FightPropData
[]
A
ddProps
;
private
FightPropData
[]
a
ddProps
;
private
int
U
nlockMaxLevel
;
private
int
u
nlockMaxLevel
;
private
int
R
equiredPlayerLevel
;
private
int
r
equiredPlayerLevel
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
(
W
eaponPromoteId
<<
8
)
+
P
romoteLevel
;
return
(
w
eaponPromoteId
<<
8
)
+
p
romoteLevel
;
}
}
public
int
getWeaponPromoteId
()
{
public
int
getWeaponPromoteId
()
{
return
W
eaponPromoteId
;
return
w
eaponPromoteId
;
}
}
public
int
getPromoteLevel
()
{
public
int
getPromoteLevel
()
{
return
P
romoteLevel
;
return
p
romoteLevel
;
}
}
public
ItemParamData
[]
getCostItems
()
{
public
ItemParamData
[]
getCostItems
()
{
return
C
ostItems
;
return
c
ostItems
;
}
}
public
int
getCoinCost
()
{
public
int
getCoinCost
()
{
return
C
oinCost
;
return
c
oinCost
;
}
}
public
FightPropData
[]
getAddProps
()
{
public
FightPropData
[]
getAddProps
()
{
return
A
ddProps
;
return
a
ddProps
;
}
}
public
int
getUnlockMaxLevel
()
{
public
int
getUnlockMaxLevel
()
{
return
U
nlockMaxLevel
;
return
u
nlockMaxLevel
;
}
}
public
int
getRequiredPlayerLevel
()
{
public
int
getRequiredPlayerLevel
()
{
return
R
equiredPlayerLevel
;
return
r
equiredPlayerLevel
;
}
}
@Override
@Override
...
@@ -60,7 +60,7 @@ public class WeaponPromoteData extends GameResource {
...
@@ -60,7 +60,7 @@ public class WeaponPromoteData extends GameResource {
}
}
trim
.
add
(
itemParam
);
trim
.
add
(
itemParam
);
}
}
this
.
C
ostItems
=
trim
.
toArray
(
new
ItemParamData
[
trim
.
size
()]);
this
.
c
ostItems
=
trim
.
toArray
(
new
ItemParamData
[
trim
.
size
()]);
// Trim fight prop data
// Trim fight prop data
ArrayList
<
FightPropData
>
parsed
=
new
ArrayList
<>(
getAddProps
().
length
);
ArrayList
<
FightPropData
>
parsed
=
new
ArrayList
<>(
getAddProps
().
length
);
for
(
FightPropData
prop
:
getAddProps
())
{
for
(
FightPropData
prop
:
getAddProps
())
{
...
@@ -69,6 +69,6 @@ public class WeaponPromoteData extends GameResource {
...
@@ -69,6 +69,6 @@ public class WeaponPromoteData extends GameResource {
parsed
.
add
(
prop
);
parsed
.
add
(
prop
);
}
}
}
}
this
.
A
ddProps
=
parsed
.
toArray
(
new
FightPropData
[
parsed
.
size
()]);
this
.
a
ddProps
=
parsed
.
toArray
(
new
FightPropData
[
parsed
.
size
()]);
}
}
}
}
src/main/java/emu/grasscutter/data/
def
/WorldLevelData.java
→
src/main/java/emu/grasscutter/data/
excels
/WorldLevelData.java
View file @
a8293102
package
emu.grasscutter.data.
def
;
package
emu.grasscutter.data.
excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"WorldLevelExcelConfigData.json"
)
@ResourceType
(
name
=
"WorldLevelExcelConfigData.json"
)
public
class
WorldLevelData
extends
GameResource
{
public
class
WorldLevelData
extends
GameResource
{
private
int
L
evel
;
private
int
l
evel
;
private
int
M
onsterLevel
;
private
int
m
onsterLevel
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
L
evel
;
return
this
.
l
evel
;
}
}
public
int
getMonsterLevel
()
{
public
int
getMonsterLevel
()
{
return
M
onsterLevel
;
return
m
onsterLevel
;
}
}
@Override
@Override
...
...
src/main/java/emu/grasscutter/database/DatabaseHelper.java
View file @
a8293102
...
@@ -3,10 +3,12 @@ package emu.grasscutter.database;
...
@@ -3,10 +3,12 @@ package emu.grasscutter.database;
import
java.util.List
;
import
java.util.List
;
import
com.mongodb.client.result.DeleteResult
;
import
com.mongodb.client.result.DeleteResult
;
import
dev.morphia.query.FindOptions
;
import
dev.morphia.query.FindOptions
;
import
dev.morphia.query.Sort
;
import
dev.morphia.query.Sort
;
import
dev.morphia.query.experimental.filters.Filters
;
import
dev.morphia.query.experimental.filters.Filters
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.friends.Friendship
;
...
@@ -14,27 +16,34 @@ import emu.grasscutter.game.gacha.GachaRecord;
...
@@ -14,27 +16,34 @@ import emu.grasscutter.game.gacha.GachaRecord;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
static
com
.
mongodb
.
client
.
model
.
Filters
.
eq
;
public
final
class
DatabaseHelper
{
public
final
class
DatabaseHelper
{
public
static
Account
createAccount
(
String
username
)
{
public
static
Account
createAccount
(
String
username
)
{
return
createAccountWith
I
d
(
username
,
0
);
return
createAccountWith
Ui
d
(
username
,
0
);
}
}
public
static
Account
createAccountWith
I
d
(
String
username
,
int
reserved
I
d
)
{
public
static
Account
createAccountWith
Ui
d
(
String
username
,
int
reserved
Ui
d
)
{
// Unique names only
// Unique names only
Account
exists
=
DatabaseHelper
.
getAccountByName
(
username
);
if
(
DatabaseHelper
.
checkIfAccountExists
(
username
))
{
if
(
exists
!=
null
)
{
return
null
;
return
null
;
}
}
// Make sure there are no id collisions
// Make sure there are no id collisions
if
(
reserved
I
d
>
0
)
{
if
(
reserved
Ui
d
>
0
)
{
// Cannot make account with the same uid as the server console
// Cannot make account with the same uid as the server console
if
(
reservedId
==
GameConstants
.
SERVER_CONSOLE_UID
)
{
if
(
reservedUid
==
GameConstants
.
SERVER_CONSOLE_UID
)
{
return
null
;
}
if
(
DatabaseHelper
.
checkIfAccountExists
(
reservedUid
))
{
return
null
;
return
null
;
}
}
exists
=
DatabaseHelper
.
getAccountByPlayerId
(
reservedId
);
if
(
exists
!=
null
)
{
// Make sure no existing player already has this id.
if
(
DatabaseHelper
.
checkIfPlayerExists
(
reservedUid
))
{
return
null
;
return
null
;
}
}
}
}
...
@@ -44,8 +53,8 @@ public final class DatabaseHelper {
...
@@ -44,8 +53,8 @@ public final class DatabaseHelper {
account
.
setUsername
(
username
);
account
.
setUsername
(
username
);
account
.
setId
(
Integer
.
toString
(
DatabaseManager
.
getNextId
(
account
)));
account
.
setId
(
Integer
.
toString
(
DatabaseManager
.
getNextId
(
account
)));
if
(
reserved
I
d
>
0
)
{
if
(
reserved
Ui
d
>
0
)
{
account
.
setPlayer
I
d
(
reserved
I
d
);
account
.
set
Reserved
Player
Ui
d
(
reserved
Ui
d
);
}
}
DatabaseHelper
.
saveAccount
(
account
);
DatabaseHelper
.
saveAccount
(
account
);
...
@@ -74,118 +83,158 @@ public final class DatabaseHelper {
...
@@ -74,118 +83,158 @@ public final class DatabaseHelper {
}
}
public
static
Account
getAccountByName
(
String
username
)
{
public
static
Account
getAccountByName
(
String
username
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"username"
,
username
)).
first
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"username"
,
username
)).
first
();
}
}
public
static
Account
getAccountByToken
(
String
token
)
{
public
static
Account
getAccountByToken
(
String
token
)
{
if
(
token
==
null
)
return
null
;
if
(
token
==
null
)
return
null
;
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"token"
,
token
)).
first
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"token"
,
token
)).
first
();
}
}
public
static
Account
getAccountBySessionKey
(
String
sessionKey
)
{
public
static
Account
getAccountBySessionKey
(
String
sessionKey
)
{
if
(
sessionKey
==
null
)
return
null
;
if
(
sessionKey
==
null
)
return
null
;
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"sessionKey"
,
sessionKey
)).
first
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"sessionKey"
,
sessionKey
)).
first
();
}
}
public
static
Account
getAccountById
(
String
uid
)
{
public
static
Account
getAccountById
(
String
uid
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
uid
)).
first
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
uid
)).
first
();
}
}
public
static
Account
getAccountByPlayerId
(
int
playerId
)
{
public
static
Account
getAccountByPlayerId
(
int
playerId
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"
p
layerId"
,
playerId
)).
first
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"
reservedP
layerId"
,
playerId
)).
first
();
}
}
public
static
boolean
deleteAccount
(
String
username
)
{
public
static
boolean
checkIfAccountExists
(
String
name
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"username"
,
username
)).
delete
().
getDeletedCount
()
>
0
;
return
DatabaseManager
.
getGameDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"username"
,
name
)).
count
()
>
0
;
}
public
static
boolean
checkIfAccountExists
(
int
reservedUid
)
{
return
DatabaseManager
.
getGameDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"reservedPlayerId"
,
reservedUid
)).
count
()
>
0
;
}
public
static
void
deleteAccount
(
Account
target
)
{
// To delete an account, we need to also delete all the other documents in the database that reference the account.
// This should optimally be wrapped inside a transaction, to make sure an error thrown mid-way does not leave the
// database in an inconsistent state, but unfortunately Mongo only supports that when we have a replica set ...
Player
player
=
Grasscutter
.
getGameServer
().
getPlayerByAccountId
(
target
.
getId
());
if
(
player
!=
null
)
{
// Close session first
player
.
getSession
().
close
();
// Delete data from collections
DatabaseManager
.
getGameDatabase
().
getCollection
(
"mail"
).
deleteMany
(
eq
(
"ownerUid"
,
player
.
getUid
()));
DatabaseManager
.
getGameDatabase
().
getCollection
(
"avatars"
).
deleteMany
(
eq
(
"ownerId"
,
player
.
getUid
()));
DatabaseManager
.
getGameDatabase
().
getCollection
(
"gachas"
).
deleteMany
(
eq
(
"ownerId"
,
player
.
getUid
()));
DatabaseManager
.
getGameDatabase
().
getCollection
(
"items"
).
deleteMany
(
eq
(
"ownerId"
,
player
.
getUid
()));
DatabaseManager
.
getGameDatabase
().
getCollection
(
"quests"
).
deleteMany
(
eq
(
"ownerUid"
,
player
.
getUid
()));
// Delete friendships.
// Here, we need to make sure to not only delete the deleted account's friendships,
// but also all friendship entries for that account's friends.
DatabaseManager
.
getGameDatabase
().
getCollection
(
"friendships"
).
deleteMany
(
eq
(
"ownerId"
,
player
.
getUid
()));
DatabaseManager
.
getGameDatabase
().
getCollection
(
"friendships"
).
deleteMany
(
eq
(
"friendId"
,
player
.
getUid
()));
// Delete the player last.
DatabaseManager
.
getGameDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"id"
,
player
.
getUid
())).
delete
();
}
// Finally, delete the account itself.
DatabaseManager
.
getGameDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"id"
,
target
.
getId
())).
delete
();
}
}
public
static
List
<
Player
>
getAllPlayers
()
{
public
static
List
<
Player
>
getAllPlayers
()
{
return
DatabaseManager
.
getDatastore
().
find
(
Player
.
class
).
stream
().
toList
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Player
.
class
).
stream
().
toList
();
}
}
public
static
Player
getPlayerBy
I
d
(
int
id
)
{
public
static
Player
getPlayerBy
Ui
d
(
int
id
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
();
}
}
public
static
boolean
checkPlayerExists
(
int
id
)
{
public
static
Player
getPlayerByAccount
(
Account
account
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
()
!=
null
;
return
DatabaseManager
.
getGameDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"accountId"
,
account
.
getId
())).
first
();
}
public
static
boolean
checkIfPlayerExists
(
int
uid
)
{
return
DatabaseManager
.
getGameDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
uid
)).
count
()
>
0
;
}
}
public
static
synchronized
Player
cre
atePlayer
(
Player
character
,
int
reservedId
)
{
public
static
synchronized
Player
gener
atePlayer
Uid
(
Player
character
,
int
reservedId
)
{
// Check if reserved id
// Check if reserved id
int
id
;
int
id
;
if
(
reservedId
>
0
&&
!
checkPlayerExists
(
reservedId
))
{
if
(
reservedId
>
0
&&
!
check
If
PlayerExists
(
reservedId
))
{
id
=
reservedId
;
id
=
reservedId
;
character
.
setUid
(
id
);
character
.
setUid
(
id
);
}
else
{
}
else
{
do
{
do
{
id
=
DatabaseManager
.
getNextId
(
character
);
id
=
DatabaseManager
.
getNextId
(
character
);
}
}
while
(
checkPlayerExists
(
id
));
while
(
check
If
PlayerExists
(
id
));
character
.
setUid
(
id
);
character
.
setUid
(
id
);
}
}
// Save to database
// Save to database
DatabaseManager
.
getDatastore
().
save
(
character
);
DatabaseManager
.
get
Game
Datastore
().
save
(
character
);
return
character
;
return
character
;
}
}
public
static
synchronized
int
getNextPlayerId
(
int
reservedId
)
{
public
static
synchronized
int
getNextPlayerId
(
int
reservedId
)
{
// Check if reserved id
// Check if reserved id
int
id
;
int
id
;
if
(
reservedId
>
0
&&
!
checkPlayerExists
(
reservedId
))
{
if
(
reservedId
>
0
&&
!
check
If
PlayerExists
(
reservedId
))
{
id
=
reservedId
;
id
=
reservedId
;
}
else
{
}
else
{
do
{
do
{
id
=
DatabaseManager
.
getNextId
(
Player
.
class
);
id
=
DatabaseManager
.
getNextId
(
Player
.
class
);
}
}
while
(
checkPlayerExists
(
id
));
while
(
check
If
PlayerExists
(
id
));
}
}
return
id
;
return
id
;
}
}
public
static
void
savePlayer
(
Player
character
)
{
public
static
void
savePlayer
(
Player
character
)
{
DatabaseManager
.
getDatastore
().
save
(
character
);
DatabaseManager
.
get
Game
Datastore
().
save
(
character
);
}
}
public
static
void
saveAvatar
(
Avatar
avatar
)
{
public
static
void
saveAvatar
(
Avatar
avatar
)
{
DatabaseManager
.
getDatastore
().
save
(
avatar
);
DatabaseManager
.
get
Game
Datastore
().
save
(
avatar
);
}
}
public
static
List
<
Avatar
>
getAvatars
(
Player
player
)
{
public
static
List
<
Avatar
>
getAvatars
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Avatar
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Avatar
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
void
saveItem
(
GameItem
item
)
{
public
static
void
saveItem
(
GameItem
item
)
{
DatabaseManager
.
getDatastore
().
save
(
item
);
DatabaseManager
.
get
Game
Datastore
().
save
(
item
);
}
}
public
static
boolean
deleteItem
(
GameItem
item
)
{
public
static
boolean
deleteItem
(
GameItem
item
)
{
DeleteResult
result
=
DatabaseManager
.
getDatastore
().
delete
(
item
);
DeleteResult
result
=
DatabaseManager
.
get
Game
Datastore
().
delete
(
item
);
return
result
.
wasAcknowledged
();
return
result
.
wasAcknowledged
();
}
}
public
static
List
<
GameItem
>
getInventoryItems
(
Player
player
)
{
public
static
List
<
GameItem
>
getInventoryItems
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
GameItem
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
GameItem
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
List
<
Friendship
>
getFriends
(
Player
player
)
{
public
static
List
<
Friendship
>
getFriends
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
List
<
Friendship
>
getReverseFriends
(
Player
player
)
{
public
static
List
<
Friendship
>
getReverseFriends
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
eq
(
"friendId"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
eq
(
"friendId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
void
saveFriendship
(
Friendship
friendship
)
{
public
static
void
saveFriendship
(
Friendship
friendship
)
{
DatabaseManager
.
getDatastore
().
save
(
friendship
);
DatabaseManager
.
get
Game
Datastore
().
save
(
friendship
);
}
}
public
static
void
deleteFriendship
(
Friendship
friendship
)
{
public
static
void
deleteFriendship
(
Friendship
friendship
)
{
DatabaseManager
.
getDatastore
().
delete
(
friendship
);
DatabaseManager
.
get
Game
Datastore
().
delete
(
friendship
);
}
}
public
static
Friendship
getReverseFriendship
(
Friendship
friendship
)
{
public
static
Friendship
getReverseFriendship
(
Friendship
friendship
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
and
(
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
and
(
Filters
.
eq
(
"ownerId"
,
friendship
.
getFriendId
()),
Filters
.
eq
(
"ownerId"
,
friendship
.
getFriendId
()),
Filters
.
eq
(
"friendId"
,
friendship
.
getOwnerId
())
Filters
.
eq
(
"friendId"
,
friendship
.
getOwnerId
())
)).
first
();
)).
first
();
...
@@ -196,7 +245,7 @@ public final class DatabaseHelper {
...
@@ -196,7 +245,7 @@ public final class DatabaseHelper {
}
}
public
static
List
<
GachaRecord
>
getGachaRecords
(
int
ownerId
,
int
page
,
int
gachaType
,
int
pageSize
){
public
static
List
<
GachaRecord
>
getGachaRecords
(
int
ownerId
,
int
page
,
int
gachaType
,
int
pageSize
){
return
DatabaseManager
.
getDatastore
().
find
(
GachaRecord
.
class
).
filter
(
return
DatabaseManager
.
get
Game
Datastore
().
find
(
GachaRecord
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
ownerId
),
Filters
.
eq
(
"ownerId"
,
ownerId
),
Filters
.
eq
(
"gachaType"
,
gachaType
)
Filters
.
eq
(
"gachaType"
,
gachaType
)
).
iterator
(
new
FindOptions
()
).
iterator
(
new
FindOptions
()
...
@@ -211,7 +260,7 @@ public final class DatabaseHelper {
...
@@ -211,7 +260,7 @@ public final class DatabaseHelper {
}
}
public
static
long
getGachaRecordsMaxPage
(
int
ownerId
,
int
page
,
int
gachaType
,
int
pageSize
){
public
static
long
getGachaRecordsMaxPage
(
int
ownerId
,
int
page
,
int
gachaType
,
int
pageSize
){
long
count
=
DatabaseManager
.
getDatastore
().
find
(
GachaRecord
.
class
).
filter
(
long
count
=
DatabaseManager
.
get
Game
Datastore
().
find
(
GachaRecord
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
ownerId
),
Filters
.
eq
(
"ownerId"
,
ownerId
),
Filters
.
eq
(
"gachaType"
,
gachaType
)
Filters
.
eq
(
"gachaType"
,
gachaType
)
).
count
();
).
count
();
...
@@ -219,19 +268,31 @@ public final class DatabaseHelper {
...
@@ -219,19 +268,31 @@ public final class DatabaseHelper {
}
}
public
static
void
saveGachaRecord
(
GachaRecord
gachaRecord
){
public
static
void
saveGachaRecord
(
GachaRecord
gachaRecord
){
DatabaseManager
.
getDatastore
().
save
(
gachaRecord
);
DatabaseManager
.
get
Game
Datastore
().
save
(
gachaRecord
);
}
}
public
static
List
<
Mail
>
getAllMail
(
Player
player
)
{
public
static
List
<
Mail
>
getAllMail
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Mail
.
class
).
filter
(
Filters
.
eq
(
"ownerUid"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
get
Game
Datastore
().
find
(
Mail
.
class
).
filter
(
Filters
.
eq
(
"ownerUid"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
void
saveMail
(
Mail
mail
)
{
public
static
void
saveMail
(
Mail
mail
)
{
DatabaseManager
.
getDatastore
().
save
(
mail
);
DatabaseManager
.
get
Game
Datastore
().
save
(
mail
);
}
}
public
static
boolean
deleteMail
(
Mail
mail
)
{
public
static
boolean
deleteMail
(
Mail
mail
)
{
DeleteResult
result
=
DatabaseManager
.
getDatastore
().
delete
(
mail
);
DeleteResult
result
=
DatabaseManager
.
get
Game
Datastore
().
delete
(
mail
);
return
result
.
wasAcknowledged
();
return
result
.
wasAcknowledged
();
}
}
public
static
List
<
GameMainQuest
>
getAllQuests
(
Player
player
)
{
return
DatabaseManager
.
getGameDatastore
().
find
(
GameMainQuest
.
class
).
filter
(
Filters
.
eq
(
"ownerUid"
,
player
.
getUid
())).
stream
().
toList
();
}
public
static
void
saveQuest
(
GameMainQuest
quest
)
{
DatabaseManager
.
getGameDatastore
().
save
(
quest
);
}
public
static
boolean
deleteQuest
(
GameMainQuest
quest
)
{
return
DatabaseManager
.
getGameDatastore
().
delete
(
quest
).
wasAcknowledged
();
}
}
}
src/main/java/emu/grasscutter/database/DatabaseManager.java
View file @
a8293102
package
emu.grasscutter.database
;
package
emu.grasscutter.database
;
import
com.mongodb.MongoClientURI
;
import
com.mongodb.MongoCommandException
;
import
com.mongodb.MongoCommandException
;
import
com.mongodb.client.MongoClient
;
import
com.mongodb.client.MongoClient
;
import
com.mongodb.client.MongoClients
;
import
com.mongodb.client.MongoClients
;
...
@@ -20,69 +19,70 @@ import emu.grasscutter.game.gacha.GachaRecord;
...
@@ -20,69 +19,70 @@ import emu.grasscutter.game.gacha.GachaRecord;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameQuest
;
public
final
class
DatabaseManager
{
import
static
emu
.
grasscutter
.
Configuration
.*;
private
static
MongoClient
mongoClient
;
private
static
MongoClient
dispatchMongoClient
;
private
static
Datastore
datastore
;
public
final
class
DatabaseManager
{
private
static
Datastore
gameDatastore
;
private
static
Datastore
dispatchDatastore
;
private
static
Datastore
dispatchDatastore
;
private
static
final
Class
<?>[]
mappedClasses
=
new
Class
<?>[]
{
private
static
final
Class
<?>[]
mappedClasses
=
new
Class
<?>[]
{
DatabaseCounter
.
class
,
Account
.
class
,
Player
.
class
,
Avatar
.
class
,
GameItem
.
class
,
Friendship
.
class
,
GachaRecord
.
class
,
Mail
.
class
DatabaseCounter
.
class
,
Account
.
class
,
Player
.
class
,
Avatar
.
class
,
GameItem
.
class
,
Friendship
.
class
,
GachaRecord
.
class
,
Mail
.
class
,
GameMainQuest
.
class
};
};
public
static
Datastore
getDatastore
()
{
public
static
Datastore
get
Game
Datastore
()
{
return
d
atastore
;
return
gameD
atastore
;
}
}
public
static
MongoDatabase
getDatabase
()
{
public
static
MongoDatabase
get
Game
Database
()
{
return
getDatastore
().
getDatabase
();
return
get
Game
Datastore
().
getDatabase
();
}
}
// Yes. I very dislike this method. However, this will be good for now.
// Yes. I very dislike this method. However, this will be good for now.
// TODO: Add dispatch routes for player account management
// TODO: Add dispatch routes for player account management
public
static
Datastore
getAccountDatastore
()
{
public
static
Datastore
getAccountDatastore
()
{
if
(
Grasscutter
.
getConfig
().
R
unMode
==
ServerRunMode
.
GAME_ONLY
)
{
if
(
SERVER
.
r
unMode
==
ServerRunMode
.
GAME_ONLY
)
{
return
dispatchDatastore
;
return
dispatchDatastore
;
}
else
{
}
else
{
return
d
atastore
;
return
gameD
atastore
;
}
}
}
}
public
static
void
initialize
()
{
public
static
void
initialize
()
{
// Initialize
// Initialize
MongoClient
m
ongoClient
=
MongoClients
.
create
(
Grasscutter
.
getConfig
().
Database
Ur
l
);
MongoClient
gameM
ongoClient
=
MongoClients
.
create
(
DATABASE
.
game
.
connection
Ur
i
);
// Set mapper options.
// Set mapper options.
MapperOptions
mapperOptions
=
MapperOptions
.
builder
()
MapperOptions
mapperOptions
=
MapperOptions
.
builder
()
.
storeEmpties
(
true
).
storeNulls
(
false
).
build
();
.
storeEmpties
(
true
).
storeNulls
(
false
).
build
();
// Create data store.
// Create data store.
d
atastore
=
Morphia
.
createDatastore
(
m
ongoClient
,
Grasscutter
.
getConfig
().
DatabaseC
ollection
,
mapperOptions
);
gameD
atastore
=
Morphia
.
createDatastore
(
gameM
ongoClient
,
DATABASE
.
game
.
c
ollection
,
mapperOptions
);
// Map classes.
// Map classes.
d
atastore
.
getMapper
().
map
(
mappedClasses
);
gameD
atastore
.
getMapper
().
map
(
mappedClasses
);
// Ensure indexes
// Ensure indexes
try
{
try
{
d
atastore
.
ensureIndexes
();
gameD
atastore
.
ensureIndexes
();
}
catch
(
MongoCommandException
exception
)
{
}
catch
(
MongoCommandException
exception
)
{
Grasscutter
.
getLogger
().
info
(
"Mongo index error: "
,
exception
);
Grasscutter
.
getLogger
().
info
(
"Mongo index error: "
,
exception
);
// Duplicate index error
// Duplicate index error
if
(
exception
.
getCode
()
==
85
)
{
if
(
exception
.
getCode
()
==
85
)
{
// Drop all indexes and re add them
// Drop all indexes and re add them
MongoIterable
<
String
>
collections
=
d
atastore
.
getDatabase
().
listCollectionNames
();
MongoIterable
<
String
>
collections
=
gameD
atastore
.
getDatabase
().
listCollectionNames
();
for
(
String
name
:
collections
)
{
for
(
String
name
:
collections
)
{
d
atastore
.
getDatabase
().
getCollection
(
name
).
dropIndexes
();
gameD
atastore
.
getDatabase
().
getCollection
(
name
).
dropIndexes
();
}
}
// Add back indexes
// Add back indexes
d
atastore
.
ensureIndexes
();
gameD
atastore
.
ensureIndexes
();
}
}
}
}
if
(
Grasscutter
.
getConfig
().
R
unMode
==
ServerRunMode
.
GAME_ONLY
)
{
if
(
SERVER
.
r
unMode
==
ServerRunMode
.
GAME_ONLY
)
{
dispatchMongoClient
=
MongoClients
.
create
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
DispatchServerDatabase
Ur
l
);
MongoClient
dispatchMongoClient
=
MongoClients
.
create
(
DATABASE
.
server
.
connection
Ur
i
);
dispatchDatastore
=
Morphia
.
createDatastore
(
dispatchMongoClient
,
Grasscutter
.
getConfig
().
getGameServerOptions
().
DispatchServerDatabaseC
ollection
);
dispatchDatastore
=
Morphia
.
createDatastore
(
dispatchMongoClient
,
DATABASE
.
server
.
c
ollection
);
// Ensure indexes for dispatch server
// Ensure indexes for dispatch server
try
{
try
{
...
@@ -104,14 +104,14 @@ public final class DatabaseManager {
...
@@ -104,14 +104,14 @@ public final class DatabaseManager {
}
}
public
static
synchronized
int
getNextId
(
Class
<?>
c
)
{
public
static
synchronized
int
getNextId
(
Class
<?>
c
)
{
DatabaseCounter
counter
=
getDatastore
().
find
(
DatabaseCounter
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
c
.
getSimpleName
())).
first
();
DatabaseCounter
counter
=
get
Game
Datastore
().
find
(
DatabaseCounter
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
c
.
getSimpleName
())).
first
();
if
(
counter
==
null
)
{
if
(
counter
==
null
)
{
counter
=
new
DatabaseCounter
(
c
.
getSimpleName
());
counter
=
new
DatabaseCounter
(
c
.
getSimpleName
());
}
}
try
{
try
{
return
counter
.
getNextId
();
return
counter
.
getNextId
();
}
finally
{
}
finally
{
getDatastore
().
save
(
counter
);
get
Game
Datastore
().
save
(
counter
);
}
}
}
}
...
...
src/main/java/emu/grasscutter/game/Account.java
View file @
a8293102
...
@@ -5,12 +5,12 @@ import emu.grasscutter.database.DatabaseHelper;
...
@@ -5,12 +5,12 @@ import emu.grasscutter.database.DatabaseHelper;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
import
java.util.
ArrayList
;
import
java.util.
*
;
import
java.util.
Li
st
;
import
java.util.st
ream.Stream
;
import
org.bson.Document
;
import
org.bson.Document
;
import
com.mongodb.DBObject
;
import
static
emu
.
grasscutter
.
Configuration
.*
;
@Entity
(
value
=
"accounts"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"accounts"
,
useDiscriminator
=
false
)
public
class
Account
{
public
class
Account
{
...
@@ -21,16 +21,18 @@ public class Account {
...
@@ -21,16 +21,18 @@ public class Account {
private
String
username
;
private
String
username
;
private
String
password
;
// Unused for now
private
String
password
;
// Unused for now
@AlsoLoad
(
"playerUid"
)
private
int
p
layerId
;
private
int
reservedP
layerId
;
private
String
email
;
private
String
email
;
private
String
token
;
private
String
token
;
private
String
sessionKey
;
// Session token for dispatch server
private
String
sessionKey
;
// Session token for dispatch server
private
List
<
String
>
permissions
;
private
List
<
String
>
permissions
;
private
Locale
locale
;
@Deprecated
@Deprecated
public
Account
()
{
public
Account
()
{
this
.
permissions
=
new
ArrayList
<>();
this
.
permissions
=
new
ArrayList
<>();
this
.
locale
=
LANGUAGE
;
}
}
public
String
getId
()
{
public
String
getId
()
{
...
@@ -65,12 +67,12 @@ public class Account {
...
@@ -65,12 +67,12 @@ public class Account {
this
.
token
=
token
;
this
.
token
=
token
;
}
}
public
int
getPlayerUid
()
{
public
int
get
Reserved
PlayerUid
()
{
return
this
.
p
layerId
;
return
this
.
reservedP
layerId
;
}
}
public
void
setPlayer
I
d
(
int
playerId
)
{
public
void
set
Reserved
Player
Ui
d
(
int
playerId
)
{
this
.
p
layerId
=
playerId
;
this
.
reservedP
layerId
=
playerId
;
}
}
public
String
getEmail
()
{
public
String
getEmail
()
{
...
@@ -95,6 +97,14 @@ public class Account {
...
@@ -95,6 +97,14 @@ public class Account {
return
this
.
sessionKey
;
return
this
.
sessionKey
;
}
}
public
Locale
getLocale
()
{
return
locale
;
}
public
void
setLocale
(
Locale
locale
)
{
this
.
locale
=
locale
;
}
/**
/**
* The collection of a player's permissions.
* The collection of a player's permissions.
*/
*/
...
@@ -107,13 +117,49 @@ public class Account {
...
@@ -107,13 +117,49 @@ public class Account {
this
.
permissions
.
add
(
permission
);
return
true
;
this
.
permissions
.
add
(
permission
);
return
true
;
}
}
public
static
boolean
permissionMatchesWildcard
(
String
wildcard
,
String
[]
permissionParts
)
{
String
[]
wildcardParts
=
wildcard
.
split
(
"\\."
);
if
(
permissionParts
.
length
<
wildcardParts
.
length
)
{
// A longer wildcard can never match a shorter permission
return
false
;
}
for
(
int
i
=
0
;
i
<
wildcardParts
.
length
;
i
++)
{
switch
(
wildcardParts
[
i
])
{
case
"**"
:
// Recursing match
return
true
;
case
"*"
:
// Match only one layer
if
(
i
>=
(
permissionParts
.
length
-
1
))
{
return
true
;
}
break
;
default
:
// This layer isn't a wildcard, it needs to match exactly
if
(!
wildcardParts
[
i
].
equals
(
permissionParts
[
i
]))
{
return
false
;
}
}
}
// At this point the wildcard will have matched every layer, but if it is shorter then the permission then this is not a match at this point (no **).
return
(
wildcardParts
.
length
==
permissionParts
.
length
);
}
public
boolean
hasPermission
(
String
permission
)
{
public
boolean
hasPermission
(
String
permission
)
{
return
this
.
permissions
.
contains
(
permission
)
||
if
(
this
.
permissions
.
contains
(
"*"
)
&&
this
.
permissions
.
size
()
==
1
)
return
true
;
this
.
permissions
.
contains
(
"*"
)
||
(
this
.
permissions
.
contains
(
"player"
)
||
this
.
permissions
.
contains
(
"player.*"
))
&&
permission
.
startsWith
(
"player."
)
||
// Add default permissions if it doesn't exist
(
this
.
permissions
.
contains
(
"server"
)
||
this
.
permissions
.
contains
(
"server.*"
))
&&
permission
.
startsWith
(
"server."
);
List
<
String
>
permissions
=
Stream
.
of
(
this
.
permissions
,
Arrays
.
asList
(
ACCOUNT
.
defaultPermissions
))
.
flatMap
(
Collection:
:
stream
)
.
distinct
().
toList
();
if
(
permissions
.
contains
(
permission
))
return
true
;
String
[]
permissionParts
=
permission
.
split
(
"\\."
);
for
(
String
p
:
permissions
)
{
if
(
p
.
startsWith
(
"-"
)
&&
permissionMatchesWildcard
(
p
.
substring
(
1
),
permissionParts
))
return
false
;
if
(
permissionMatchesWildcard
(
p
,
permissionParts
))
return
true
;
}
return
permissions
.
contains
(
"*"
);
}
}
public
boolean
removePermission
(
String
permission
)
{
public
boolean
removePermission
(
String
permission
)
{
return
this
.
permissions
.
remove
(
permission
);
return
this
.
permissions
.
remove
(
permission
);
}
}
...
@@ -135,5 +181,10 @@ public class Account {
...
@@ -135,5 +181,10 @@ public class Account {
if
(!
document
.
containsKey
(
"permissions"
))
{
if
(!
document
.
containsKey
(
"permissions"
))
{
this
.
addPermission
(
"*"
);
this
.
addPermission
(
"*"
);
}
}
// Set account default language as server default language
if
(!
document
.
containsKey
(
"locale"
))
{
this
.
locale
=
LANGUAGE
;
}
}
}
}
}
src/main/java/emu/grasscutter/game/ability/AbilityManager.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.game.ability
;
import
java.util.Optional
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.binout.AbilityModifierEntry
;
import
emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction
;
import
emu.grasscutter.data.excels.AvatarSkillDepotData
;
import
emu.grasscutter.data.excels.ItemData
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityClientGadget
;
import
emu.grasscutter.game.entity.EntityItem
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.AbilityActionGenerateElemBall
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryHeadOuterClass.AbilityInvokeEntryHead
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.proto.AbilityMetaModifierChangeOuterClass.AbilityMetaModifierChange
;
import
emu.grasscutter.net.proto.AbilityMetaReInitOverrideMapOuterClass.AbilityMetaReInitOverrideMap
;
import
emu.grasscutter.net.proto.AbilityMixinCostStaminaOuterClass.AbilityMixinCostStamina
;
import
emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry
;
import
emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
public
class
AbilityManager
{
private
Player
player
;
public
AbilityManager
(
Player
player
)
{
this
.
player
=
player
;
}
public
Player
getPlayer
()
{
return
this
.
player
;
}
public
void
onAbilityInvoke
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
// Grasscutter.getLogger().info(invoke.getArgumentType() + " (" + invoke.getArgumentTypeValue() + "): " + Utils.bytesToHex(invoke.toByteArray()));
switch
(
invoke
.
getArgumentType
())
{
case
ABILITY_INVOKE_ARGUMENT_META_OVERRIDE_PARAM:
handleOverrideParam
(
invoke
);
break
;
case
ABILITY_INVOKE_ARGUMENT_META_REINIT_OVERRIDEMAP:
handleReinitOverrideMap
(
invoke
);
break
;
case
ABILITY_INVOKE_ARGUMENT_META_MODIFIER_CHANGE:
handleModifierChange
(
invoke
);
break
;
case
ABILITY_INVOKE_ARGUMENT_MIXIN_COST_STAMINA:
handleMixinCostStamina
(
invoke
);
break
;
case
ABILITY_INVOKE_ARGUMENT_ACTION_GENERATE_ELEM_BALL:
handleGenerateElemBall
(
invoke
);
break
;
default
:
break
;
}
}
private
void
handleOverrideParam
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
GameEntity
entity
=
player
.
getScene
().
getEntityById
(
invoke
.
getEntityId
());
if
(
entity
==
null
)
{
return
;
}
AbilityScalarValueEntry
entry
=
AbilityScalarValueEntry
.
parseFrom
(
invoke
.
getAbilityData
());
entity
.
getMetaOverrideMap
().
put
(
entry
.
getKey
().
getStr
(),
entry
.
getFloatValue
());
}
private
void
handleReinitOverrideMap
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
GameEntity
entity
=
player
.
getScene
().
getEntityById
(
invoke
.
getEntityId
());
if
(
entity
==
null
)
{
return
;
}
AbilityMetaReInitOverrideMap
map
=
AbilityMetaReInitOverrideMap
.
parseFrom
(
invoke
.
getAbilityData
());
for
(
AbilityScalarValueEntry
entry
:
map
.
getOverrideMapList
())
{
entity
.
getMetaOverrideMap
().
put
(
entry
.
getKey
().
getStr
(),
entry
.
getFloatValue
());
}
}
private
void
handleModifierChange
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
GameEntity
target
=
player
.
getScene
().
getEntityById
(
invoke
.
getEntityId
());
if
(
target
==
null
)
{
return
;
}
AbilityInvokeEntryHead
head
=
invoke
.
getHead
();
if
(
head
==
null
)
{
return
;
}
AbilityMetaModifierChange
data
=
AbilityMetaModifierChange
.
parseFrom
(
invoke
.
getAbilityData
());
if
(
data
==
null
)
{
return
;
}
GameEntity
sourceEntity
=
player
.
getScene
().
getEntityById
(
data
.
getApplyEntityId
());
if
(
sourceEntity
==
null
)
{
return
;
}
// This is not how it works but we will keep it for now since healing abilities dont work properly anyways
if
(
data
.
getAction
()
==
ModifierAction
.
ADDED
&&
data
.
getParentAbilityName
()
!=
null
)
{
// Handle add modifier here
String
modifierString
=
data
.
getParentAbilityName
().
getStr
();
AbilityModifierEntry
modifier
=
GameData
.
getAbilityModifiers
().
get
(
modifierString
);
if
(
modifier
!=
null
&&
modifier
.
getOnAdded
().
size
()
>
0
)
{
for
(
AbilityModifierAction
action
:
modifier
.
getOnAdded
())
{
invokeAction
(
action
,
target
,
sourceEntity
);
}
}
// Add to meta modifier list
target
.
getMetaModifiers
().
put
(
head
.
getInstancedModifierId
(),
modifierString
);
}
else
if
(
data
.
getAction
()
==
ModifierAction
.
REMOVED
)
{
String
modifierString
=
target
.
getMetaModifiers
().
get
(
head
.
getInstancedModifierId
());
if
(
modifierString
!=
null
)
{
// Get modifier and call on remove event
AbilityModifierEntry
modifier
=
GameData
.
getAbilityModifiers
().
get
(
modifierString
);
if
(
modifier
!=
null
&&
modifier
.
getOnRemoved
().
size
()
>
0
)
{
for
(
AbilityModifierAction
action
:
modifier
.
getOnRemoved
())
{
invokeAction
(
action
,
target
,
sourceEntity
);
}
}
// Remove from meta modifiers
target
.
getMetaModifiers
().
remove
(
head
.
getInstancedModifierId
());
}
}
}
private
void
handleMixinCostStamina
(
AbilityInvokeEntry
invoke
)
throws
InvalidProtocolBufferException
{
AbilityMixinCostStamina
costStamina
=
AbilityMixinCostStamina
.
parseFrom
((
invoke
.
getAbilityData
()));
getPlayer
().
getStaminaManager
().
handleMixinCostStamina
(
costStamina
.
getIsSwim
());
}
private
void
handleGenerateElemBall
(
AbilityInvokeEntry
invoke
)
throws
InvalidProtocolBufferException
{
this
.
player
.
getEnergyManager
().
handleGenerateElemBall
(
invoke
);
}
private
void
invokeAction
(
AbilityModifierAction
action
,
GameEntity
target
,
GameEntity
sourceEntity
)
{
switch
(
action
.
type
)
{
case
HealHP
->
{
if
(
action
.
amount
==
null
)
{
return
;
}
float
healAmount
=
0
;
if
(
action
.
amount
.
isDynamic
&&
action
.
amount
.
dynamicKey
!=
null
)
{
healAmount
=
sourceEntity
.
getMetaOverrideMap
().
getOrDefault
(
action
.
amount
.
dynamicKey
,
0
f
);
}
if
(
healAmount
>
0
)
{
target
.
heal
(
healAmount
);
}
}
case
LoseHP
->
{
if
(
action
.
amountByTargetCurrentHPRatio
==
null
)
{
return
;
}
float
damageAmount
=
0
;
if
(
action
.
amount
.
isDynamic
&&
action
.
amount
.
dynamicKey
!=
null
)
{
damageAmount
=
sourceEntity
.
getMetaOverrideMap
().
getOrDefault
(
action
.
amount
.
dynamicKey
,
0
f
);
}
if
(
damageAmount
>
0
)
{
target
.
damage
(
damageAmount
);
}
}
}
}
}
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
a8293102
...
@@ -17,24 +17,24 @@ import dev.morphia.annotations.PostLoad;
...
@@ -17,24 +17,24 @@ import dev.morphia.annotations.PostLoad;
import
dev.morphia.annotations.PrePersist
;
import
dev.morphia.annotations.PrePersist
;
import
dev.morphia.annotations.Transient
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.binout.OpenConfigEntry
;
import
emu.grasscutter.data.binout.OpenConfigEntry.SkillPointModifier
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.excels.AvatarData
;
import
emu.grasscutter.data.custom.OpenConfigEntry.SkillPointModifier
;
import
emu.grasscutter.data.excels.AvatarPromoteData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.excels.AvatarSkillData
;
import
emu.grasscutter.data.def.AvatarPromoteData
;
import
emu.grasscutter.data.excels.AvatarSkillDepotData
;
import
emu.grasscutter.data.def.AvatarSkillData
;
import
emu.grasscutter.data.excels.AvatarTalentData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.data.excels.EquipAffixData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens
;
import
emu.grasscutter.data.excels.ProudSkillData
;
import
emu.grasscutter.data.def.AvatarTalentData
;
import
emu.grasscutter.data.excels.ReliquaryAffixData
;
import
emu.grasscutter.data.def.EquipAffixData
;
import
emu.grasscutter.data.excels.ReliquaryLevelData
;
import
emu.grasscutter.data.def.ItemData.WeaponProperty
;
import
emu.grasscutter.data.excels.ReliquaryMainPropData
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.data.excels.ReliquarySetData
;
import
emu.grasscutter.data.def.ReliquaryAffixData
;
import
emu.grasscutter.data.excels.WeaponCurveData
;
import
emu.grasscutter.data.def.ReliquaryLevelData
;
import
emu.grasscutter.data.excels.WeaponPromoteData
;
import
emu.grasscutter.data.def.ReliquaryMainPropData
;
import
emu.grasscutter.data.excels.AvatarSkillDepotData.InherentProudSkillOpens
;
import
emu.grasscutter.data.def.ReliquarySetData
;
import
emu.grasscutter.data.excels.ItemData.WeaponProperty
;
import
emu.grasscutter.data.def.WeaponCurveData
;
import
emu.grasscutter.data.def.WeaponPromoteData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.EquipType
;
...
@@ -62,6 +62,8 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
...
@@ -62,6 +62,8 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
static
emu
.
grasscutter
.
Configuration
.
GAME_OPTIONS
;
@Entity
(
value
=
"avatars"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"avatars"
,
useDiscriminator
=
false
)
public
class
Avatar
{
public
class
Avatar
{
@Id
private
ObjectId
id
;
@Id
private
ObjectId
id
;
...
@@ -69,6 +71,7 @@ public class Avatar {
...
@@ -69,6 +71,7 @@ public class Avatar {
@Transient
private
Player
owner
;
@Transient
private
Player
owner
;
@Transient
private
AvatarData
data
;
@Transient
private
AvatarData
data
;
@Transient
private
AvatarSkillDepotData
skillDepot
;
@Transient
private
long
guid
;
// Player unique id
@Transient
private
long
guid
;
// Player unique id
private
int
avatarId
;
// Id of avatar
private
int
avatarId
;
// Id of avatar
...
@@ -78,6 +81,7 @@ public class Avatar {
...
@@ -78,6 +81,7 @@ public class Avatar {
private
int
satiation
;
// ?
private
int
satiation
;
// ?
private
int
satiationPenalty
;
// ?
private
int
satiationPenalty
;
// ?
private
float
currentHp
;
private
float
currentHp
;
private
float
currentEnergy
;
@Transient
private
final
Int2ObjectMap
<
GameItem
>
equips
;
@Transient
private
final
Int2ObjectMap
<
GameItem
>
equips
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
...
@@ -103,8 +107,8 @@ public class Avatar {
...
@@ -103,8 +107,8 @@ public class Avatar {
private
int
nameCardRewardId
;
private
int
nameCardRewardId
;
private
int
nameCardId
;
private
int
nameCardId
;
@Deprecated
// Do not use. Morhpia only!
public
Avatar
()
{
public
Avatar
()
{
// Morhpia only!
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
...
@@ -140,13 +144,13 @@ public class Avatar {
...
@@ -140,13 +144,13 @@ public class Avatar {
}
}
// Skill depot
// Skill depot
this
.
setSkillDepot
(
getAvatarData
().
getSkillDepot
());
this
.
setSkillDepot
Data
(
getAvatarData
().
getSkillDepot
());
// Set stats
// Set stats
this
.
recalcStats
();
this
.
recalcStats
();
this
.
currentHp
=
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
this
.
currentHp
=
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
this
.
currentHp
);
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
this
.
currentHp
);
this
.
currentEnergy
=
0
f
;
// Load handler
// Load handler
this
.
onLoad
();
this
.
onLoad
();
}
}
...
@@ -164,7 +168,8 @@ public class Avatar {
...
@@ -164,7 +168,8 @@ public class Avatar {
}
}
protected
void
setAvatarData
(
AvatarData
data
)
{
protected
void
setAvatarData
(
AvatarData
data
)
{
this
.
data
=
data
;
if
(
this
.
data
!=
null
)
return
;
this
.
data
=
data
;
// Used while loading this from the database
}
}
public
int
getOwnerId
()
{
public
int
getOwnerId
()
{
...
@@ -257,9 +262,19 @@ public class Avatar {
...
@@ -257,9 +262,19 @@ public class Avatar {
return
skillDepotId
;
return
skillDepotId
;
}
}
public
void
setSkillDepot
(
AvatarSkillDepotData
skillDepot
)
{
public
AvatarSkillDepotData
getSkillDepot
()
{
// Set id
return
skillDepot
;
}
protected
void
setSkillDepot
(
AvatarSkillDepotData
skillDepot
)
{
if
(
this
.
skillDepot
!=
null
)
return
;
this
.
skillDepot
=
skillDepot
;
// Used while loading this from the database
}
public
void
setSkillDepotData
(
AvatarSkillDepotData
skillDepot
)
{
// Set id and depot
this
.
skillDepotId
=
skillDepot
.
getId
();
this
.
skillDepotId
=
skillDepot
.
getId
();
this
.
skillDepot
=
skillDepot
;
// Clear, then add skills
// Clear, then add skills
getSkillLevelMap
().
clear
();
getSkillLevelMap
().
clear
();
if
(
skillDepot
.
getEnergySkill
()
>
0
)
{
if
(
skillDepot
.
getEnergySkill
()
>
0
)
{
...
@@ -344,6 +359,34 @@ public class Avatar {
...
@@ -344,6 +359,34 @@ public class Avatar {
this
.
currentHp
=
currentHp
;
this
.
currentHp
=
currentHp
;
}
}
public
void
setCurrentEnergy
()
{
if
(
GAME_OPTIONS
.
energyUsage
)
{
this
.
setCurrentEnergy
(
this
.
currentEnergy
);
}
}
public
void
setCurrentEnergy
(
float
currentEnergy
)
{
if
(
this
.
getSkillDepot
()
!=
null
&&
this
.
getSkillDepot
().
getEnergySkillData
()
!=
null
)
{
ElementType
element
=
this
.
getSkillDepot
().
getElementType
();
this
.
setFightProperty
(
element
.
getMaxEnergyProp
(),
this
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
if
(
GAME_OPTIONS
.
energyUsage
)
{
this
.
setFightProperty
(
element
.
getCurEnergyProp
(),
currentEnergy
);
}
else
{
this
.
setFightProperty
(
element
.
getCurEnergyProp
(),
this
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
}
}
}
public
void
setCurrentEnergy
(
FightProperty
curEnergyProp
,
float
currentEnergy
)
{
if
(
GAME_OPTIONS
.
energyUsage
)
{
this
.
setFightProperty
(
curEnergyProp
,
currentEnergy
);
this
.
currentEnergy
=
currentEnergy
;
this
.
save
();
}
}
public
Int2FloatOpenHashMap
getFightProperties
()
{
public
Int2FloatOpenHashMap
getFightProperties
()
{
return
fightProp
;
return
fightProp
;
}
}
...
@@ -481,6 +524,9 @@ public class Avatar {
...
@@ -481,6 +524,9 @@ public class Avatar {
// Get hp percent, set to 100% if none
// Get hp percent, set to 100% if none
float
hpPercent
=
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
<=
0
?
1
f
:
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
/
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
float
hpPercent
=
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
<=
0
?
1
f
:
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
/
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
// Store current energy value for later
float
currentEnergy
=
(
this
.
getSkillDepot
()
!=
null
)
?
this
.
getFightProperty
(
this
.
getSkillDepot
().
getElementType
().
getCurEnergyProp
())
:
0
f
;
// Clear properties
// Clear properties
this
.
getFightProperties
().
clear
();
this
.
getFightProperties
().
clear
();
...
@@ -499,11 +545,7 @@ public class Avatar {
...
@@ -499,11 +545,7 @@ public class Avatar {
}
}
// Set energy usage
// Set energy usage
if
(
data
.
getSkillDepot
()
!=
null
&&
data
.
getSkillDepot
().
getEnergySkillData
()
!=
null
)
{
setCurrentEnergy
(
currentEnergy
);
ElementType
element
=
data
.
getSkillDepot
().
getElementType
();
this
.
setFightProperty
(
element
.
getEnergyProperty
(),
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
this
.
setFightProperty
((
element
.
getEnergyProperty
().
getId
()
%
70
)
+
1000
,
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
}
// Artifacts
// Artifacts
for
(
int
slotId
=
1
;
slotId
<=
5
;
slotId
++)
{
for
(
int
slotId
=
1
;
slotId
<=
5
;
slotId
++)
{
...
...
src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java
View file @
a8293102
...
@@ -4,7 +4,8 @@ import java.util.Iterator;
...
@@ -4,7 +4,8 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.excels.AvatarData
;
import
emu.grasscutter.data.excels.AvatarSkillDepotData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
...
@@ -139,12 +140,14 @@ public class AvatarStorage implements Iterable<Avatar> {
...
@@ -139,12 +140,14 @@ public class AvatarStorage implements Iterable<Avatar> {
}
}
AvatarData
avatarData
=
GameData
.
getAvatarDataMap
().
get
(
avatar
.
getAvatarId
());
AvatarData
avatarData
=
GameData
.
getAvatarDataMap
().
get
(
avatar
.
getAvatarId
());
if
(
avatarData
==
null
)
{
AvatarSkillDepotData
skillDepot
=
GameData
.
getAvatarSkillDepotDataMap
().
get
(
avatar
.
getSkillDepotId
());
if
(
avatarData
==
null
||
skillDepot
==
null
)
{
continue
;
continue
;
}
}
// Set ownerships
// Set ownerships
avatar
.
setAvatarData
(
avatarData
);
avatar
.
setAvatarData
(
avatarData
);
avatar
.
setSkillDepot
(
skillDepot
);
avatar
.
setOwner
(
getPlayer
());
avatar
.
setOwner
(
getPlayer
());
// Force recalc of const boosted skills
// Force recalc of const boosted skills
...
...
src/main/java/emu/grasscutter/game/combine/CombineManger.java
View file @
a8293102
package
emu.grasscutter.game.combine
;
package
emu.grasscutter.game.combine
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.CombineData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.excels.CombineData
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.proto.RetcodeOuterClass
;
import
emu.grasscutter.net.proto.RetcodeOuterClass
;
...
@@ -71,7 +72,7 @@ public class CombineManger {
...
@@ -71,7 +72,7 @@ public class CombineManger {
CombineResult
result
=
new
CombineResult
();
CombineResult
result
=
new
CombineResult
();
result
.
setMaterial
(
List
.
of
());
result
.
setMaterial
(
List
.
of
());
result
.
setResult
(
List
.
of
(
new
CombineData
.
CombineItemPair
(
combineData
.
getResultItemId
(),
result
.
setResult
(
List
.
of
(
new
ItemParamData
(
combineData
.
getResultItemId
(),
combineData
.
getResultItemCount
()
*
count
)));
combineData
.
getResultItemCount
()
*
count
)));
// TODO lucky characters
// TODO lucky characters
result
.
setExtra
(
List
.
of
());
result
.
setExtra
(
List
.
of
());
...
...
src/main/java/emu/grasscutter/game/combine/CombineResult.java
View file @
a8293102
package
emu.grasscutter.game.combine
;
package
emu.grasscutter.game.combine
;
import
emu.grasscutter.data.def.CombineData
;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.excels.CombineData
;
public
class
CombineResult
{
public
class
CombineResult
{
private
List
<
CombineData
.
CombineItemPair
>
material
;
private
List
<
ItemParamData
>
material
;
private
List
<
CombineData
.
CombineItemPair
>
result
;
private
List
<
ItemParamData
>
result
;
private
List
<
CombineData
.
CombineItemPair
>
extra
;
private
List
<
ItemParamData
>
extra
;
private
List
<
CombineData
.
CombineItemPair
>
back
;
private
List
<
ItemParamData
>
back
;
public
List
<
CombineData
.
CombineItemPair
>
getMaterial
()
{
public
List
<
ItemParamData
>
getMaterial
()
{
return
material
;
return
material
;
}
}
public
void
setMaterial
(
List
<
CombineData
.
CombineItemPair
>
material
)
{
public
void
setMaterial
(
List
<
ItemParamData
>
material
)
{
this
.
material
=
material
;
this
.
material
=
material
;
}
}
public
List
<
CombineData
.
CombineItemPair
>
getResult
()
{
public
List
<
ItemParamData
>
getResult
()
{
return
result
;
return
result
;
}
}
public
void
setResult
(
List
<
CombineData
.
CombineItemPair
>
result
)
{
public
void
setResult
(
List
<
ItemParamData
>
result
)
{
this
.
result
=
result
;
this
.
result
=
result
;
}
}
public
List
<
CombineData
.
CombineItemPair
>
getExtra
()
{
public
List
<
ItemParamData
>
getExtra
()
{
return
extra
;
return
extra
;
}
}
public
void
setExtra
(
List
<
CombineData
.
CombineItemPair
>
extra
)
{
public
void
setExtra
(
List
<
ItemParamData
>
extra
)
{
this
.
extra
=
extra
;
this
.
extra
=
extra
;
}
}
public
List
<
CombineData
.
CombineItemPair
>
getBack
()
{
public
List
<
ItemParamData
>
getBack
()
{
return
back
;
return
back
;
}
}
public
void
setBack
(
List
<
CombineData
.
CombineItemPair
>
back
)
{
public
void
setBack
(
List
<
ItemParamData
>
back
)
{
this
.
back
=
back
;
this
.
back
=
back
;
}
}
...
...
Prev
1
…
3
4
5
6
7
8
9
10
11
…
21
Next
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