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
1c36f078
Commit
1c36f078
authored
Apr 26, 2022
by
Melledy
Browse files
Renamed all references to a certain game
parent
6b8902be
Changes
270
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/def/ReliquaryMainPropData.java
View file @
1c36f078
package
emu.grasscutter.data.def
;
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
@ResourceType
(
name
=
"ReliquaryMainPropExcelConfigData.json"
)
@ResourceType
(
name
=
"ReliquaryMainPropExcelConfigData.json"
)
public
class
ReliquaryMainPropData
extends
G
enshin
Resource
{
public
class
ReliquaryMainPropData
extends
G
ame
Resource
{
private
int
Id
;
private
int
Id
;
private
int
PropDepotId
;
private
int
PropDepotId
;
...
...
src/main/java/emu/grasscutter/data/def/ReliquarySetData.java
View file @
1c36f078
package
emu.grasscutter.data.def
;
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"ReliquarySetExcelConfigData.json"
)
@ResourceType
(
name
=
"ReliquarySetExcelConfigData.json"
)
public
class
ReliquarySetData
extends
G
enshin
Resource
{
public
class
ReliquarySetData
extends
G
ame
Resource
{
private
int
SetId
;
private
int
SetId
;
private
int
[]
SetNeedNum
;
private
int
[]
SetNeedNum
;
private
int
EquipAffixId
;
private
int
EquipAffixId
;
...
...
src/main/java/emu/grasscutter/data/def/RewardData.java
View file @
1c36f078
...
@@ -2,12 +2,12 @@ package emu.grasscutter.data.def;
...
@@ -2,12 +2,12 @@ package emu.grasscutter.data.def;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.common.RewardItemData
;
import
emu.grasscutter.data.common.RewardItemData
;
@ResourceType
(
name
=
"RewardExcelConfigData.json"
)
@ResourceType
(
name
=
"RewardExcelConfigData.json"
)
public
class
RewardData
extends
G
enshin
Resource
{
public
class
RewardData
extends
G
ame
Resource
{
public
int
RewardId
;
public
int
RewardId
;
public
List
<
RewardItemData
>
RewardItemList
;
public
List
<
RewardItemData
>
RewardItemList
;
...
...
src/main/java/emu/grasscutter/data/def/SceneData.java
View file @
1c36f078
package
emu.grasscutter.data.def
;
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.props.SceneType
;
import
emu.grasscutter.game.props.SceneType
;
@ResourceType
(
name
=
"SceneExcelConfigData.json"
)
@ResourceType
(
name
=
"SceneExcelConfigData.json"
)
public
class
SceneData
extends
G
enshin
Resource
{
public
class
SceneData
extends
G
ame
Resource
{
private
int
Id
;
private
int
Id
;
private
SceneType
SceneType
;
private
SceneType
SceneType
;
private
String
ScriptData
;
private
String
ScriptData
;
...
...
src/main/java/emu/grasscutter/data/def/WeaponCurveData.java
View file @
1c36f078
...
@@ -4,12 +4,12 @@ import java.util.HashMap;
...
@@ -4,12 +4,12 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.common.CurveInfo
;
import
emu.grasscutter.data.common.CurveInfo
;
@ResourceType
(
name
=
"WeaponCurveExcelConfigData.json"
)
@ResourceType
(
name
=
"WeaponCurveExcelConfigData.json"
)
public
class
WeaponCurveData
extends
G
enshin
Resource
{
public
class
WeaponCurveData
extends
G
ame
Resource
{
private
int
Level
;
private
int
Level
;
private
CurveInfo
[]
CurveInfos
;
private
CurveInfo
[]
CurveInfos
;
...
...
src/main/java/emu/grasscutter/data/def/WeaponLevelData.java
View file @
1c36f078
package
emu.grasscutter.data.def
;
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"WeaponLevelExcelConfigData.json"
)
@ResourceType
(
name
=
"WeaponLevelExcelConfigData.json"
)
public
class
WeaponLevelData
extends
G
enshin
Resource
{
public
class
WeaponLevelData
extends
G
ame
Resource
{
private
int
Level
;
private
int
Level
;
private
int
[]
RequiredExps
;
private
int
[]
RequiredExps
;
...
...
src/main/java/emu/grasscutter/data/def/WeaponPromoteData.java
View file @
1c36f078
package
emu.grasscutter.data.def
;
package
emu.grasscutter.data.def
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.common.ItemParamData
;
@ResourceType
(
name
=
"WeaponPromoteExcelConfigData.json"
)
@ResourceType
(
name
=
"WeaponPromoteExcelConfigData.json"
)
public
class
WeaponPromoteData
extends
G
enshin
Resource
{
public
class
WeaponPromoteData
extends
G
ame
Resource
{
private
int
WeaponPromoteId
;
private
int
WeaponPromoteId
;
private
int
PromoteLevel
;
private
int
PromoteLevel
;
...
...
src/main/java/emu/grasscutter/data/def/WorldLevelData.java
View file @
1c36f078
package
emu.grasscutter.data.def
;
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
"WorldLevelExcelConfigData.json"
)
@ResourceType
(
name
=
"WorldLevelExcelConfigData.json"
)
public
class
WorldLevelData
extends
G
enshin
Resource
{
public
class
WorldLevelData
extends
G
ame
Resource
{
private
int
Level
;
private
int
Level
;
private
int
MonsterLevel
;
private
int
MonsterLevel
;
...
...
src/main/java/emu/grasscutter/database/DatabaseHelper.java
View file @
1c36f078
...
@@ -4,12 +4,12 @@ import java.util.List;
...
@@ -4,12 +4,12 @@ import java.util.List;
import
com.mongodb.client.result.DeleteResult
;
import
com.mongodb.client.result.DeleteResult
;
import
dev.morphia.query.experimental.filters.Filters
;
import
dev.morphia.query.experimental.filters.Filters
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
public
final
class
DatabaseHelper
{
public
final
class
DatabaseHelper
{
public
static
Account
createAccount
(
String
username
)
{
public
static
Account
createAccount
(
String
username
)
{
...
@@ -26,7 +26,7 @@ public final class DatabaseHelper {
...
@@ -26,7 +26,7 @@ public final class DatabaseHelper {
// Make sure there are no id collisions
// Make sure there are no id collisions
if
(
reservedId
>
0
)
{
if
(
reservedId
>
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
==
G
enshin
Constants
.
SERVER_CONSOLE_UID
)
{
if
(
reservedId
==
G
ame
Constants
.
SERVER_CONSOLE_UID
)
{
return
null
;
return
null
;
}
}
exists
=
DatabaseHelper
.
getAccountByPlayerId
(
reservedId
);
exists
=
DatabaseHelper
.
getAccountByPlayerId
(
reservedId
);
...
@@ -90,19 +90,19 @@ public final class DatabaseHelper {
...
@@ -90,19 +90,19 @@ public final class DatabaseHelper {
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"username"
,
username
)).
delete
().
getDeletedCount
()
>
0
;
return
DatabaseManager
.
getDatastore
().
find
(
Account
.
class
).
filter
(
Filters
.
eq
(
"username"
,
username
)).
delete
().
getDeletedCount
()
>
0
;
}
}
public
static
List
<
Genshin
Player
>
getAllPlayers
()
{
public
static
List
<
Player
>
getAllPlayers
()
{
return
DatabaseManager
.
getDatastore
().
find
(
Genshin
Player
.
class
).
stream
().
toList
();
return
DatabaseManager
.
getDatastore
().
find
(
Player
.
class
).
stream
().
toList
();
}
}
public
static
Genshin
Player
getPlayerById
(
int
id
)
{
public
static
Player
getPlayerById
(
int
id
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Genshin
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
();
return
DatabaseManager
.
getDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
();
}
}
public
static
boolean
checkPlayerExists
(
int
id
)
{
public
static
boolean
checkPlayerExists
(
int
id
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Genshin
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
()
!=
null
;
return
DatabaseManager
.
getDatastore
().
find
(
Player
.
class
).
filter
(
Filters
.
eq
(
"_id"
,
id
)).
first
()
!=
null
;
}
}
public
static
synchronized
Genshin
Player
createPlayer
(
Genshin
Player
character
,
int
reservedId
)
{
public
static
synchronized
Player
createPlayer
(
Player
character
,
int
reservedId
)
{
// Check if reserved id
// Check if reserved id
int
id
;
int
id
;
if
(
reservedId
>
0
&&
!
checkPlayerExists
(
reservedId
))
{
if
(
reservedId
>
0
&&
!
checkPlayerExists
(
reservedId
))
{
...
@@ -127,42 +127,42 @@ public final class DatabaseHelper {
...
@@ -127,42 +127,42 @@ public final class DatabaseHelper {
id
=
reservedId
;
id
=
reservedId
;
}
else
{
}
else
{
do
{
do
{
id
=
DatabaseManager
.
getNextId
(
Genshin
Player
.
class
);
id
=
DatabaseManager
.
getNextId
(
Player
.
class
);
}
}
while
(
checkPlayerExists
(
id
));
while
(
checkPlayerExists
(
id
));
}
}
return
id
;
return
id
;
}
}
public
static
void
savePlayer
(
Genshin
Player
character
)
{
public
static
void
savePlayer
(
Player
character
)
{
DatabaseManager
.
getDatastore
().
save
(
character
);
DatabaseManager
.
getDatastore
().
save
(
character
);
}
}
public
static
void
saveAvatar
(
Genshin
Avatar
avatar
)
{
public
static
void
saveAvatar
(
Avatar
avatar
)
{
DatabaseManager
.
getDatastore
().
save
(
avatar
);
DatabaseManager
.
getDatastore
().
save
(
avatar
);
}
}
public
static
List
<
Genshin
Avatar
>
getAvatars
(
Genshin
Player
player
)
{
public
static
List
<
Avatar
>
getAvatars
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
Genshin
Avatar
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
getDatastore
().
find
(
Avatar
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
void
saveItem
(
G
enshin
Item
item
)
{
public
static
void
saveItem
(
G
ame
Item
item
)
{
DatabaseManager
.
getDatastore
().
save
(
item
);
DatabaseManager
.
getDatastore
().
save
(
item
);
}
}
public
static
boolean
deleteItem
(
G
enshin
Item
item
)
{
public
static
boolean
deleteItem
(
G
ame
Item
item
)
{
DeleteResult
result
=
DatabaseManager
.
getDatastore
().
delete
(
item
);
DeleteResult
result
=
DatabaseManager
.
getDatastore
().
delete
(
item
);
return
result
.
wasAcknowledged
();
return
result
.
wasAcknowledged
();
}
}
public
static
List
<
G
enshin
Item
>
getInventoryItems
(
Genshin
Player
player
)
{
public
static
List
<
G
ame
Item
>
getInventoryItems
(
Player
player
)
{
return
DatabaseManager
.
getDatastore
().
find
(
G
enshin
Item
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
return
DatabaseManager
.
getDatastore
().
find
(
G
ame
Item
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
List
<
Friendship
>
getFriends
(
Genshin
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
.
getDatastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
eq
(
"ownerId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
public
static
List
<
Friendship
>
getReverseFriends
(
Genshin
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
.
getDatastore
().
find
(
Friendship
.
class
).
filter
(
Filters
.
eq
(
"friendId"
,
player
.
getUid
())).
stream
().
toList
();
}
}
...
...
src/main/java/emu/grasscutter/database/DatabaseManager.java
View file @
1c36f078
...
@@ -13,10 +13,10 @@ import dev.morphia.mapping.MapperOptions;
...
@@ -13,10 +13,10 @@ import dev.morphia.mapping.MapperOptions;
import
dev.morphia.query.experimental.filters.Filters
;
import
dev.morphia.query.experimental.filters.Filters
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
public
final
class
DatabaseManager
{
public
final
class
DatabaseManager
{
...
@@ -27,7 +27,7 @@ public final class DatabaseManager {
...
@@ -27,7 +27,7 @@ public final class DatabaseManager {
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
,
Genshin
Player
.
class
,
Genshin
Avatar
.
class
,
G
enshin
Item
.
class
,
Friendship
.
class
DatabaseCounter
.
class
,
Account
.
class
,
Player
.
class
,
Avatar
.
class
,
G
ame
Item
.
class
,
Friendship
.
class
};
};
public
static
Datastore
getDatastore
()
{
public
static
Datastore
getDatastore
()
{
...
...
src/main/java/emu/grasscutter/game/CoopRequest.java
View file @
1c36f078
package
emu.grasscutter.game
;
package
emu.grasscutter.game
;
public
class
CoopRequest
{
public
class
CoopRequest
{
private
final
Genshin
Player
requester
;
private
final
Player
requester
;
private
final
long
requestTime
;
private
final
long
requestTime
;
private
final
long
expireTime
;
private
final
long
expireTime
;
public
CoopRequest
(
Genshin
Player
requester
)
{
public
CoopRequest
(
Player
requester
)
{
this
.
requester
=
requester
;
this
.
requester
=
requester
;
this
.
requestTime
=
System
.
currentTimeMillis
();
this
.
requestTime
=
System
.
currentTimeMillis
();
this
.
expireTime
=
this
.
requestTime
+
10000
;
this
.
expireTime
=
this
.
requestTime
+
10000
;
}
}
public
Genshin
Player
getRequester
()
{
public
Player
getRequester
()
{
return
requester
;
return
requester
;
}
}
...
...
src/main/java/emu/grasscutter/game/InvokeHandler.java
View file @
1c36f078
...
@@ -2,16 +2,16 @@ package emu.grasscutter.game;
...
@@ -2,16 +2,16 @@ package emu.grasscutter.game;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.proto.ForwardTypeOuterClass.ForwardType
;
import
emu.grasscutter.net.proto.ForwardTypeOuterClass.ForwardType
;
public
class
InvokeHandler
<
T
>
{
public
class
InvokeHandler
<
T
>
{
private
final
List
<
T
>
entryListForwardAll
;
private
final
List
<
T
>
entryListForwardAll
;
private
final
List
<
T
>
entryListForwardAllExceptCur
;
private
final
List
<
T
>
entryListForwardAllExceptCur
;
private
final
List
<
T
>
entryListForwardHost
;
private
final
List
<
T
>
entryListForwardHost
;
private
final
Class
<?
extends
Genshin
Packet
>
packetClass
;
private
final
Class
<?
extends
Base
Packet
>
packetClass
;
public
InvokeHandler
(
Class
<?
extends
Genshin
Packet
>
packetClass
)
{
public
InvokeHandler
(
Class
<?
extends
Base
Packet
>
packetClass
)
{
this
.
entryListForwardAll
=
new
ArrayList
<>();
this
.
entryListForwardAll
=
new
ArrayList
<>();
this
.
entryListForwardAllExceptCur
=
new
ArrayList
<>();
this
.
entryListForwardAllExceptCur
=
new
ArrayList
<>();
this
.
entryListForwardHost
=
new
ArrayList
<>();
this
.
entryListForwardHost
=
new
ArrayList
<>();
...
@@ -28,7 +28,7 @@ public class InvokeHandler<T> {
...
@@ -28,7 +28,7 @@ public class InvokeHandler<T> {
}
}
}
}
public
synchronized
void
update
(
Genshin
Player
player
)
{
public
synchronized
void
update
(
Player
player
)
{
if
(
player
.
getWorld
()
==
null
)
{
if
(
player
.
getWorld
()
==
null
)
{
this
.
entryListForwardAll
.
clear
();
this
.
entryListForwardAll
.
clear
();
this
.
entryListForwardAllExceptCur
.
clear
();
this
.
entryListForwardAllExceptCur
.
clear
();
...
@@ -38,17 +38,17 @@ public class InvokeHandler<T> {
...
@@ -38,17 +38,17 @@ public class InvokeHandler<T> {
try
{
try
{
if
(
entryListForwardAll
.
size
()
>
0
)
{
if
(
entryListForwardAll
.
size
()
>
0
)
{
Genshin
Packet
packet
=
packetClass
.
getDeclaredConstructor
(
List
.
class
).
newInstance
(
this
.
entryListForwardAll
);
Base
Packet
packet
=
packetClass
.
getDeclaredConstructor
(
List
.
class
).
newInstance
(
this
.
entryListForwardAll
);
player
.
getScene
().
broadcastPacket
(
packet
);
player
.
getScene
().
broadcastPacket
(
packet
);
this
.
entryListForwardAll
.
clear
();
this
.
entryListForwardAll
.
clear
();
}
}
if
(
entryListForwardAllExceptCur
.
size
()
>
0
)
{
if
(
entryListForwardAllExceptCur
.
size
()
>
0
)
{
Genshin
Packet
packet
=
packetClass
.
getDeclaredConstructor
(
List
.
class
).
newInstance
(
this
.
entryListForwardAllExceptCur
);
Base
Packet
packet
=
packetClass
.
getDeclaredConstructor
(
List
.
class
).
newInstance
(
this
.
entryListForwardAllExceptCur
);
player
.
getScene
().
broadcastPacketToOthers
(
player
,
packet
);
player
.
getScene
().
broadcastPacketToOthers
(
player
,
packet
);
this
.
entryListForwardAllExceptCur
.
clear
();
this
.
entryListForwardAllExceptCur
.
clear
();
}
}
if
(
entryListForwardHost
.
size
()
>
0
)
{
if
(
entryListForwardHost
.
size
()
>
0
)
{
Genshin
Packet
packet
=
packetClass
.
getDeclaredConstructor
(
List
.
class
).
newInstance
(
this
.
entryListForwardHost
);
Base
Packet
packet
=
packetClass
.
getDeclaredConstructor
(
List
.
class
).
newInstance
(
this
.
entryListForwardHost
);
player
.
getWorld
().
getHost
().
sendPacket
(
packet
);
player
.
getWorld
().
getHost
().
sendPacket
(
packet
);
this
.
entryListForwardHost
.
clear
();
this
.
entryListForwardHost
.
clear
();
}
}
...
...
src/main/java/emu/grasscutter/game/Mail.java
View file @
1c36f078
...
@@ -57,7 +57,7 @@ public class Mail {
...
@@ -57,7 +57,7 @@ public class Mail {
this
(
title
,
content
,
"Server"
);
this
(
title
,
content
,
"Server"
);
}
}
public
MailContent
(
String
title
,
String
content
,
Genshin
Player
sender
)
{
public
MailContent
(
String
title
,
String
content
,
Player
sender
)
{
this
(
title
,
content
,
sender
.
getNickname
());
this
(
title
,
content
,
sender
.
getNickname
());
}
}
...
...
src/main/java/emu/grasscutter/game/
Genshin
Player.java
→
src/main/java/emu/grasscutter/game/Player.java
View file @
1c36f078
...
@@ -4,26 +4,26 @@ import java.time.Instant;
...
@@ -4,26 +4,26 @@ import java.time.Instant;
import
java.util.*
;
import
java.util.*
;
import
dev.morphia.annotations.*
;
import
dev.morphia.annotations.*
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.def.PlayerLevelData
;
import
emu.grasscutter.data.def.PlayerLevelData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.avatar.AvatarProfileData
;
import
emu.grasscutter.game.avatar.AvatarProfileData
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityItem
;
import
emu.grasscutter.game.entity.EntityItem
;
import
emu.grasscutter.game.entity.G
enshin
Entity
;
import
emu.grasscutter.game.entity.G
ame
Entity
;
import
emu.grasscutter.game.friends.FriendsList
;
import
emu.grasscutter.game.friends.FriendsList
;
import
emu.grasscutter.game.friends.PlayerProfile
;
import
emu.grasscutter.game.friends.PlayerProfile
;
import
emu.grasscutter.game.gacha.PlayerGachaInfo
;
import
emu.grasscutter.game.gacha.PlayerGachaInfo
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.player.PlayerBirthday
;
import
emu.grasscutter.game.player.PlayerBirthday
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.proto.CombatInvokeEntryOuterClass.CombatInvokeEntry
;
import
emu.grasscutter.net.proto.CombatInvokeEntryOuterClass.CombatInvokeEntry
;
import
emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage
;
import
emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage
;
...
@@ -46,7 +46,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
...
@@ -46,7 +46,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import
java.util.*
;
import
java.util.*
;
@Entity
(
value
=
"players"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"players"
,
useDiscriminator
=
false
)
public
class
Genshin
Player
{
public
class
Player
{
@Id
private
int
id
;
@Id
private
int
id
;
@Indexed
(
options
=
@IndexOptions
(
unique
=
true
))
private
String
accountId
;
@Indexed
(
options
=
@IndexOptions
(
unique
=
true
))
private
String
accountId
;
...
@@ -67,7 +67,7 @@ public class GenshinPlayer {
...
@@ -67,7 +67,7 @@ public class GenshinPlayer {
@Transient
private
long
nextGuid
=
0
;
@Transient
private
long
nextGuid
=
0
;
@Transient
private
int
peerId
;
@Transient
private
int
peerId
;
@Transient
private
World
world
;
@Transient
private
World
world
;
@Transient
private
Genshin
Scene
scene
;
@Transient
private
Scene
scene
;
@Transient
private
GameSession
session
;
@Transient
private
GameSession
session
;
@Transient
private
AvatarStorage
avatars
;
@Transient
private
AvatarStorage
avatars
;
@Transient
private
Inventory
inventory
;
@Transient
private
Inventory
inventory
;
...
@@ -104,7 +104,7 @@ public class GenshinPlayer {
...
@@ -104,7 +104,7 @@ public class GenshinPlayer {
@Deprecated
@Deprecated
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
// Morphia only!
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
// Morphia only!
public
Genshin
Player
()
{
public
Player
()
{
this
.
inventory
=
new
Inventory
(
this
);
this
.
inventory
=
new
Inventory
(
this
);
this
.
avatars
=
new
AvatarStorage
(
this
);
this
.
avatars
=
new
AvatarStorage
(
this
);
this
.
friendsList
=
new
FriendsList
(
this
);
this
.
friendsList
=
new
FriendsList
(
this
);
...
@@ -140,7 +140,7 @@ public class GenshinPlayer {
...
@@ -140,7 +140,7 @@ public class GenshinPlayer {
}
}
// On player creation
// On player creation
public
Genshin
Player
(
GameSession
session
)
{
public
Player
(
GameSession
session
)
{
this
();
this
();
this
.
account
=
session
.
getAccount
();
this
.
account
=
session
.
getAccount
();
this
.
accountId
=
this
.
getAccount
().
getId
();
this
.
accountId
=
this
.
getAccount
().
getId
();
...
@@ -159,7 +159,7 @@ public class GenshinPlayer {
...
@@ -159,7 +159,7 @@ public class GenshinPlayer {
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_RESIN
,
160
);
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_RESIN
,
160
);
this
.
getFlyCloakList
().
add
(
140001
);
this
.
getFlyCloakList
().
add
(
140001
);
this
.
getNameCardList
().
add
(
210001
);
this
.
getNameCardList
().
add
(
210001
);
this
.
getPos
().
set
(
G
enshin
Constants
.
START_POSITION
);
this
.
getPos
().
set
(
G
ame
Constants
.
START_POSITION
);
this
.
getRotation
().
set
(
0
,
307
,
0
);
this
.
getRotation
().
set
(
0
,
307
,
0
);
}
}
...
@@ -171,7 +171,7 @@ public class GenshinPlayer {
...
@@ -171,7 +171,7 @@ public class GenshinPlayer {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
long
getNextG
enshin
Guid
()
{
public
long
getNextG
ame
Guid
()
{
long
nextId
=
++
this
.
nextGuid
;
long
nextId
=
++
this
.
nextGuid
;
return
((
long
)
this
.
getUid
()
<<
32
)
+
nextId
;
return
((
long
)
this
.
getUid
()
<<
32
)
+
nextId
;
}
}
...
@@ -209,11 +209,11 @@ public class GenshinPlayer {
...
@@ -209,11 +209,11 @@ public class GenshinPlayer {
this
.
world
=
world
;
this
.
world
=
world
;
}
}
public
synchronized
Genshin
Scene
getScene
()
{
public
synchronized
Scene
getScene
()
{
return
scene
;
return
scene
;
}
}
public
synchronized
void
setScene
(
Genshin
Scene
scene
)
{
public
synchronized
void
setScene
(
Scene
scene
)
{
this
.
scene
=
scene
;
this
.
scene
=
scene
;
}
}
...
@@ -292,7 +292,7 @@ public class GenshinPlayer {
...
@@ -292,7 +292,7 @@ public class GenshinPlayer {
}
}
private
int
getExpRequired
(
int
level
)
{
private
int
getExpRequired
(
int
level
)
{
PlayerLevelData
levelData
=
G
enshin
Data
.
getPlayerLevelDataMap
().
get
(
level
);
PlayerLevelData
levelData
=
G
ame
Data
.
getPlayerLevelDataMap
().
get
(
level
);
return
levelData
!=
null
?
levelData
.
getExp
()
:
0
;
return
levelData
!=
null
?
levelData
.
getExp
()
:
0
;
}
}
...
@@ -546,9 +546,9 @@ public class GenshinPlayer {
...
@@ -546,9 +546,9 @@ public class GenshinPlayer {
}
}
public
void
rechargeMoonCard
()
{
public
void
rechargeMoonCard
()
{
LinkedList
<
G
enshin
Item
>
items
=
new
LinkedList
<
G
enshin
Item
>();
LinkedList
<
G
ame
Item
>
items
=
new
LinkedList
<
G
ame
Item
>();
for
(
int
i
=
0
;
i
<
300
;
i
++)
{
for
(
int
i
=
0
;
i
<
300
;
i
++)
{
items
.
add
(
new
G
enshin
Item
(
203
));
items
.
add
(
new
G
ame
Item
(
203
));
}
}
inventory
.
addItems
(
items
);
inventory
.
addItems
(
items
);
if
(!
moonCard
)
{
if
(!
moonCard
)
{
...
@@ -583,8 +583,8 @@ public class GenshinPlayer {
...
@@ -583,8 +583,8 @@ public class GenshinPlayer {
}
}
moonCardGetTimes
.
add
(
now
);
moonCardGetTimes
.
add
(
now
);
addMoonCardDays
(
1
);
addMoonCardDays
(
1
);
G
enshinItem
genshinI
tem
=
new
G
enshin
Item
(
201
,
90
);
G
ameItem
i
tem
=
new
G
ame
Item
(
201
,
90
);
getInventory
().
addItem
(
genshinI
tem
,
ActionReason
.
BlessingRedeemReward
);
getInventory
().
addItem
(
i
tem
,
ActionReason
.
BlessingRedeemReward
);
session
.
send
(
new
PacketCardProductRewardNotify
(
getMoonCardRemainDays
()));
session
.
send
(
new
PacketCardProductRewardNotify
(
getMoonCardRemainDays
()));
}
}
...
@@ -604,29 +604,19 @@ public class GenshinPlayer {
...
@@ -604,29 +604,19 @@ public class GenshinPlayer {
this
.
hasSentAvatarDataNotify
=
hasSentAvatarDataNotify
;
this
.
hasSentAvatarDataNotify
=
hasSentAvatarDataNotify
;
}
}
public
void
addAvatar
(
Genshin
Avatar
avatar
)
{
public
void
addAvatar
(
Avatar
avatar
)
{
boolean
result
=
getAvatars
().
addAvatar
(
avatar
);
boolean
result
=
getAvatars
().
addAvatar
(
avatar
);
if
(
result
)
{
if
(
result
)
{
// Add starting weapon
// Add starting weapon
getAvatars
().
addStartingWeapon
(
avatar
);
getAvatars
().
addStartingWeapon
(
avatar
);
// Try adding to team if possible
//List<EntityAvatar> currentTeam = this.getTeamManager().getCurrentTeam();
boolean
addedToTeam
=
false
;
/*
if (currentTeam.size() <= GenshinConstants.MAX_AVATARS_IN_TEAM) {
addedToTeam = currentTeam
}
*/
// Done
// Done
if
(
hasSentAvatarDataNotify
())
{
if
(
hasSentAvatarDataNotify
())
{
// Recalc stats
// Recalc stats
avatar
.
recalcStats
();
avatar
.
recalcStats
();
// Packet
// Packet
sendPacket
(
new
PacketAvatarAddNotify
(
avatar
,
addedToTeam
));
sendPacket
(
new
PacketAvatarAddNotify
(
avatar
,
false
));
}
}
}
else
{
}
else
{
// Failed adding avatar
// Failed adding avatar
...
@@ -659,7 +649,7 @@ public class GenshinPlayer {
...
@@ -659,7 +649,7 @@ public class GenshinPlayer {
}
}
public
void
dropMessage
(
Object
message
)
{
public
void
dropMessage
(
Object
message
)
{
this
.
sendPacket
(
new
PacketPrivateChatNotify
(
G
enshin
Constants
.
SERVER_CONSOLE_UID
,
getUid
(),
message
.
toString
()));
this
.
sendPacket
(
new
PacketPrivateChatNotify
(
G
ame
Constants
.
SERVER_CONSOLE_UID
,
getUid
(),
message
.
toString
()));
}
}
/**
/**
...
@@ -668,7 +658,7 @@ public class GenshinPlayer {
...
@@ -668,7 +658,7 @@ public class GenshinPlayer {
* @param sender The sender of the message.
* @param sender The sender of the message.
* @param message The message to send.
* @param message The message to send.
*/
*/
public
void
sendMessage
(
Genshin
Player
sender
,
Object
message
)
{
public
void
sendMessage
(
Player
sender
,
Object
message
)
{
this
.
sendPacket
(
new
PacketPrivateChatNotify
(
sender
.
getUid
(),
this
.
getUid
(),
message
.
toString
()));
this
.
sendPacket
(
new
PacketPrivateChatNotify
(
sender
.
getUid
(),
this
.
getUid
(),
message
.
toString
()));
}
}
...
@@ -714,7 +704,7 @@ public class GenshinPlayer {
...
@@ -714,7 +704,7 @@ public class GenshinPlayer {
}
}
public
void
interactWith
(
int
gadgetEntityId
)
{
public
void
interactWith
(
int
gadgetEntityId
)
{
G
enshin
Entity
entity
=
getScene
().
getEntityById
(
gadgetEntityId
);
G
ame
Entity
entity
=
getScene
().
getEntityById
(
gadgetEntityId
);
if
(
entity
==
null
)
{
if
(
entity
==
null
)
{
return
;
return
;
...
@@ -727,7 +717,7 @@ public class GenshinPlayer {
...
@@ -727,7 +717,7 @@ public class GenshinPlayer {
if
(
entity
instanceof
EntityItem
)
{
if
(
entity
instanceof
EntityItem
)
{
// Pick item
// Pick item
EntityItem
drop
=
(
EntityItem
)
entity
;
EntityItem
drop
=
(
EntityItem
)
entity
;
G
enshin
Item
item
=
new
G
enshin
Item
(
drop
.
getItemData
(),
drop
.
getCount
());
G
ame
Item
item
=
new
G
ame
Item
(
drop
.
getItemData
(),
drop
.
getCount
());
// Add to inventory
// Add to inventory
boolean
success
=
getInventory
().
addItem
(
item
,
ActionReason
.
SubfieldDrop
);
boolean
success
=
getInventory
().
addItem
(
item
,
ActionReason
.
SubfieldDrop
);
if
(
success
)
{
if
(
success
)
{
...
@@ -746,7 +736,7 @@ public class GenshinPlayer {
...
@@ -746,7 +736,7 @@ public class GenshinPlayer {
}
}
public
void
sendPacket
(
Genshin
Packet
packet
)
{
public
void
sendPacket
(
Base
Packet
packet
)
{
if
(
this
.
hasSentAvatarDataNotify
)
{
if
(
this
.
hasSentAvatarDataNotify
)
{
this
.
getSession
().
send
(
packet
);
this
.
getSession
().
send
(
packet
);
}
}
...
@@ -875,7 +865,7 @@ public class GenshinPlayer {
...
@@ -875,7 +865,7 @@ public class GenshinPlayer {
// Check if player object exists in server
// Check if player object exists in server
// TODO - optimize
// TODO - optimize
Genshin
Player
exists
=
this
.
getServer
().
getPlayerByUid
(
getUid
());
Player
exists
=
this
.
getServer
().
getPlayerByUid
(
getUid
());
if
(
exists
!=
null
)
{
if
(
exists
!=
null
)
{
exists
.
getSession
().
close
();
exists
.
getSession
().
close
();
}
}
...
...
src/main/java/emu/grasscutter/game/
Genshin
Scene.java
→
src/main/java/emu/grasscutter/game/Scene.java
View file @
1c36f078
...
@@ -12,9 +12,9 @@ import java.util.Set;
...
@@ -12,9 +12,9 @@ import java.util.Set;
import
org.danilopianini.util.SpatialIndex
;
import
org.danilopianini.util.SpatialIndex
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.G
enshin
Depot
;
import
emu.grasscutter.data.G
ame
Depot
;
import
emu.grasscutter.data.G
enshin
Resource
;
import
emu.grasscutter.data.G
ame
Resource
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.data.def.SceneData
;
import
emu.grasscutter.data.def.SceneData
;
import
emu.grasscutter.data.def.WorldLevelData
;
import
emu.grasscutter.data.def.WorldLevelData
;
...
@@ -22,14 +22,14 @@ import emu.grasscutter.game.entity.EntityAvatar;
...
@@ -22,14 +22,14 @@ import emu.grasscutter.game.entity.EntityAvatar;
import
emu.grasscutter.game.entity.EntityClientGadget
;
import
emu.grasscutter.game.entity.EntityClientGadget
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.entity.G
enshin
Entity
;
import
emu.grasscutter.game.entity.G
ame
Entity
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.props.SceneType
;
import
emu.grasscutter.game.props.SceneType
;
import
emu.grasscutter.game.world.SpawnDataEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry.SpawnGroupEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry.SpawnGroupEntry
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult
;
import
emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult
;
import
emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType
;
import
emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
...
@@ -41,11 +41,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -41,11 +41,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMaps
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMaps
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
class
Genshin
Scene
{
public
class
Scene
{
private
final
World
world
;
private
final
World
world
;
private
final
SceneData
sceneData
;
private
final
SceneData
sceneData
;
private
final
List
<
Genshin
Player
>
players
;
private
final
List
<
Player
>
players
;
private
final
Int2ObjectMap
<
G
enshin
Entity
>
entities
;
private
final
Int2ObjectMap
<
G
ame
Entity
>
entities
;
private
final
Set
<
SpawnDataEntry
>
spawnedEntities
;
private
final
Set
<
SpawnDataEntry
>
spawnedEntities
;
private
final
Set
<
SpawnDataEntry
>
deadSpawnedEntities
;
private
final
Set
<
SpawnDataEntry
>
deadSpawnedEntities
;
...
@@ -55,7 +55,7 @@ public class GenshinScene {
...
@@ -55,7 +55,7 @@ public class GenshinScene {
private
ClimateType
climate
;
private
ClimateType
climate
;
private
int
weather
;
private
int
weather
;
public
Genshin
Scene
(
World
world
,
SceneData
sceneData
)
{
public
Scene
(
World
world
,
SceneData
sceneData
)
{
this
.
world
=
world
;
this
.
world
=
world
;
this
.
sceneData
=
sceneData
;
this
.
sceneData
=
sceneData
;
this
.
players
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
this
.
players
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
...
@@ -84,7 +84,7 @@ public class GenshinScene {
...
@@ -84,7 +84,7 @@ public class GenshinScene {
return
getSceneData
().
getSceneType
();
return
getSceneData
().
getSceneType
();
}
}
public
List
<
Genshin
Player
>
getPlayers
()
{
public
List
<
Player
>
getPlayers
()
{
return
players
;
return
players
;
}
}
...
@@ -92,11 +92,11 @@ public class GenshinScene {
...
@@ -92,11 +92,11 @@ public class GenshinScene {
return
this
.
getPlayers
().
size
();
return
this
.
getPlayers
().
size
();
}
}
public
Int2ObjectMap
<
G
enshin
Entity
>
getEntities
()
{
public
Int2ObjectMap
<
G
ame
Entity
>
getEntities
()
{
return
entities
;
return
entities
;
}
}
public
G
enshin
Entity
getEntityById
(
int
id
)
{
public
G
ame
Entity
getEntityById
(
int
id
)
{
return
this
.
entities
.
get
(
id
);
return
this
.
entities
.
get
(
id
);
}
}
...
@@ -140,11 +140,11 @@ public class GenshinScene {
...
@@ -140,11 +140,11 @@ public class GenshinScene {
return
deadSpawnedEntities
;
return
deadSpawnedEntities
;
}
}
public
boolean
isInScene
(
G
enshin
Entity
entity
)
{
public
boolean
isInScene
(
G
ame
Entity
entity
)
{
return
this
.
entities
.
containsKey
(
entity
.
getId
());
return
this
.
entities
.
containsKey
(
entity
.
getId
());
}
}
public
synchronized
void
addPlayer
(
Genshin
Player
player
)
{
public
synchronized
void
addPlayer
(
Player
player
)
{
// Check if player already in
// Check if player already in
if
(
getPlayers
().
contains
(
player
))
{
if
(
getPlayers
().
contains
(
player
))
{
return
;
return
;
...
@@ -163,7 +163,7 @@ public class GenshinScene {
...
@@ -163,7 +163,7 @@ public class GenshinScene {
this
.
setupPlayerAvatars
(
player
);
this
.
setupPlayerAvatars
(
player
);
}
}
public
synchronized
void
removePlayer
(
Genshin
Player
player
)
{
public
synchronized
void
removePlayer
(
Player
player
)
{
// Remove player from scene
// Remove player from scene
getPlayers
().
remove
(
player
);
getPlayers
().
remove
(
player
);
player
.
setScene
(
null
);
player
.
setScene
(
null
);
...
@@ -182,7 +182,7 @@ public class GenshinScene {
...
@@ -182,7 +182,7 @@ public class GenshinScene {
}
}
}
}
private
void
setupPlayerAvatars
(
Genshin
Player
player
)
{
private
void
setupPlayerAvatars
(
Player
player
)
{
// Clear entities from old team
// Clear entities from old team
player
.
getTeamManager
().
getActiveTeam
().
clear
();
player
.
getTeamManager
().
getActiveTeam
().
clear
();
...
@@ -199,7 +199,7 @@ public class GenshinScene {
...
@@ -199,7 +199,7 @@ public class GenshinScene {
}
}
}
}
private
void
removePlayerAvatars
(
Genshin
Player
player
)
{
private
void
removePlayerAvatars
(
Player
player
)
{
Iterator
<
EntityAvatar
>
it
=
player
.
getTeamManager
().
getActiveTeam
().
iterator
();
Iterator
<
EntityAvatar
>
it
=
player
.
getTeamManager
().
getActiveTeam
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
this
.
removeEntity
(
it
.
next
(),
VisionType
.
VISION_REMOVE
);
this
.
removeEntity
(
it
.
next
(),
VisionType
.
VISION_REMOVE
);
...
@@ -207,7 +207,7 @@ public class GenshinScene {
...
@@ -207,7 +207,7 @@ public class GenshinScene {
}
}
}
}
public
void
spawnPlayer
(
Genshin
Player
player
)
{
public
void
spawnPlayer
(
Player
player
)
{
if
(
this
.
isInScene
(
player
.
getTeamManager
().
getCurrentAvatarEntity
()))
{
if
(
this
.
isInScene
(
player
.
getTeamManager
().
getCurrentAvatarEntity
()))
{
return
;
return
;
}
}
...
@@ -219,33 +219,33 @@ public class GenshinScene {
...
@@ -219,33 +219,33 @@ public class GenshinScene {
this
.
addEntity
(
player
.
getTeamManager
().
getCurrentAvatarEntity
());
this
.
addEntity
(
player
.
getTeamManager
().
getCurrentAvatarEntity
());
}
}
private
void
addEntityDirectly
(
G
enshin
Entity
entity
)
{
private
void
addEntityDirectly
(
G
ame
Entity
entity
)
{
getEntities
().
put
(
entity
.
getId
(),
entity
);
getEntities
().
put
(
entity
.
getId
(),
entity
);
}
}
public
synchronized
void
addEntity
(
G
enshin
Entity
entity
)
{
public
synchronized
void
addEntity
(
G
ame
Entity
entity
)
{
this
.
addEntityDirectly
(
entity
);
this
.
addEntityDirectly
(
entity
);
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
entity
));
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
entity
));
}
}
public
synchronized
void
addEntities
(
Collection
<
G
enshin
Entity
>
entities
)
{
public
synchronized
void
addEntities
(
Collection
<
G
ame
Entity
>
entities
)
{
for
(
G
enshin
Entity
entity
:
entities
)
{
for
(
G
ame
Entity
entity
:
entities
)
{
this
.
addEntityDirectly
(
entity
);
this
.
addEntityDirectly
(
entity
);
}
}
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
entities
,
VisionType
.
VISION_BORN
));
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
entities
,
VisionType
.
VISION_BORN
));
}
}
private
G
enshin
Entity
removeEntityDirectly
(
G
enshin
Entity
entity
)
{
private
G
ame
Entity
removeEntityDirectly
(
G
ame
Entity
entity
)
{
return
getEntities
().
remove
(
entity
.
getId
());
return
getEntities
().
remove
(
entity
.
getId
());
}
}
public
void
removeEntity
(
G
enshin
Entity
entity
)
{
public
void
removeEntity
(
G
ame
Entity
entity
)
{
this
.
removeEntity
(
entity
,
VisionType
.
VISION_DIE
);
this
.
removeEntity
(
entity
,
VisionType
.
VISION_DIE
);
}
}
public
synchronized
void
removeEntity
(
G
enshin
Entity
entity
,
VisionType
visionType
)
{
public
synchronized
void
removeEntity
(
G
ame
Entity
entity
,
VisionType
visionType
)
{
G
enshin
Entity
removed
=
this
.
removeEntityDirectly
(
entity
);
G
ame
Entity
removed
=
this
.
removeEntityDirectly
(
entity
);
if
(
removed
!=
null
)
{
if
(
removed
!=
null
)
{
this
.
broadcastPacket
(
new
PacketSceneEntityDisappearNotify
(
removed
,
visionType
));
this
.
broadcastPacket
(
new
PacketSceneEntityDisappearNotify
(
removed
,
visionType
));
}
}
...
@@ -258,11 +258,11 @@ public class GenshinScene {
...
@@ -258,11 +258,11 @@ public class GenshinScene {
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
newEntity
,
VisionType
.
VISION_REPLACE
,
oldEntity
.
getId
()));
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
newEntity
,
VisionType
.
VISION_REPLACE
,
oldEntity
.
getId
()));
}
}
public
void
showOtherEntities
(
Genshin
Player
player
)
{
public
void
showOtherEntities
(
Player
player
)
{
List
<
G
enshin
Entity
>
entities
=
new
LinkedList
<>();
List
<
G
ame
Entity
>
entities
=
new
LinkedList
<>();
G
enshin
Entity
currentEntity
=
player
.
getTeamManager
().
getCurrentAvatarEntity
();
G
ame
Entity
currentEntity
=
player
.
getTeamManager
().
getCurrentAvatarEntity
();
for
(
G
enshin
Entity
entity
:
this
.
getEntities
().
values
())
{
for
(
G
ame
Entity
entity
:
this
.
getEntities
().
values
())
{
if
(
entity
==
currentEntity
)
{
if
(
entity
==
currentEntity
)
{
continue
;
continue
;
}
}
...
@@ -273,8 +273,8 @@ public class GenshinScene {
...
@@ -273,8 +273,8 @@ public class GenshinScene {
}
}
public
void
handleAttack
(
AttackResult
result
)
{
public
void
handleAttack
(
AttackResult
result
)
{
//G
enshin
Entity attacker = getEntityById(result.getAttackerId());
//G
ame
Entity attacker = getEntityById(result.getAttackerId());
G
enshin
Entity
target
=
getEntityById
(
result
.
getDefenseId
());
G
ame
Entity
target
=
getEntityById
(
result
.
getDefenseId
());
if
(
target
==
null
)
{
if
(
target
==
null
)
{
return
;
return
;
...
@@ -306,7 +306,7 @@ public class GenshinScene {
...
@@ -306,7 +306,7 @@ public class GenshinScene {
}
}
}
}
public
void
killEntity
(
G
enshin
Entity
target
,
int
attackerId
)
{
public
void
killEntity
(
G
ame
Entity
target
,
int
attackerId
)
{
// Packet
// Packet
this
.
broadcastPacket
(
new
PacketLifeStateChangeNotify
(
attackerId
,
target
,
LifeState
.
LIFE_DEAD
));
this
.
broadcastPacket
(
new
PacketLifeStateChangeNotify
(
attackerId
,
target
,
LifeState
.
LIFE_DEAD
));
this
.
removeEntity
(
target
);
this
.
removeEntity
(
target
);
...
@@ -321,10 +321,10 @@ public class GenshinScene {
...
@@ -321,10 +321,10 @@ public class GenshinScene {
// TODO - Test
// TODO - Test
public
void
checkSpawns
()
{
public
void
checkSpawns
()
{
SpatialIndex
<
SpawnGroupEntry
>
list
=
G
enshin
Depot
.
getSpawnListById
(
this
.
getId
());
SpatialIndex
<
SpawnGroupEntry
>
list
=
G
ame
Depot
.
getSpawnListById
(
this
.
getId
());
Set
<
SpawnDataEntry
>
visible
=
new
HashSet
<>();
Set
<
SpawnDataEntry
>
visible
=
new
HashSet
<>();
for
(
Genshin
Player
player
:
this
.
getPlayers
())
{
for
(
Player
player
:
this
.
getPlayers
())
{
int
RANGE
=
100
;
int
RANGE
=
100
;
Collection
<
SpawnGroupEntry
>
entries
=
list
.
query
(
Collection
<
SpawnGroupEntry
>
entries
=
list
.
query
(
new
double
[]
{
player
.
getPos
().
getX
()
-
RANGE
,
player
.
getPos
().
getZ
()
-
RANGE
},
new
double
[]
{
player
.
getPos
().
getX
()
-
RANGE
,
player
.
getPos
().
getZ
()
-
RANGE
},
...
@@ -339,7 +339,7 @@ public class GenshinScene {
...
@@ -339,7 +339,7 @@ public class GenshinScene {
}
}
// World level
// World level
WorldLevelData
worldLevelData
=
G
enshin
Data
.
getWorldLevelDataMap
().
get
(
getWorld
().
getWorldLevel
());
WorldLevelData
worldLevelData
=
G
ame
Data
.
getWorldLevelDataMap
().
get
(
getWorld
().
getWorldLevel
());
int
worldLevelOverride
=
0
;
int
worldLevelOverride
=
0
;
if
(
worldLevelData
!=
null
)
{
if
(
worldLevelData
!=
null
)
{
...
@@ -347,13 +347,13 @@ public class GenshinScene {
...
@@ -347,13 +347,13 @@ public class GenshinScene {
}
}
// Todo
// Todo
List
<
G
enshin
Entity
>
toAdd
=
new
LinkedList
<>();
List
<
G
ame
Entity
>
toAdd
=
new
LinkedList
<>();
List
<
G
enshin
Entity
>
toRemove
=
new
LinkedList
<>();
List
<
G
ame
Entity
>
toRemove
=
new
LinkedList
<>();
for
(
SpawnDataEntry
entry
:
visible
)
{
for
(
SpawnDataEntry
entry
:
visible
)
{
if
(!
this
.
getSpawnedEntities
().
contains
(
entry
)
&&
!
this
.
getDeadSpawnedEntities
().
contains
(
entry
))
{
if
(!
this
.
getSpawnedEntities
().
contains
(
entry
)
&&
!
this
.
getDeadSpawnedEntities
().
contains
(
entry
))
{
// Spawn entity
// Spawn entity
MonsterData
data
=
G
enshin
Data
.
getMonsterDataMap
().
get
(
entry
.
getMonsterId
());
MonsterData
data
=
G
ame
Data
.
getMonsterDataMap
().
get
(
entry
.
getMonsterId
());
if
(
data
==
null
)
{
if
(
data
==
null
)
{
continue
;
continue
;
...
@@ -373,7 +373,7 @@ public class GenshinScene {
...
@@ -373,7 +373,7 @@ public class GenshinScene {
}
}
}
}
for
(
G
enshin
Entity
entity
:
this
.
getEntities
().
values
())
{
for
(
G
ame
Entity
entity
:
this
.
getEntities
().
values
())
{
if
(
entity
.
getSpawnEntry
()
!=
null
&&
!
visible
.
contains
(
entity
.
getSpawnEntry
()))
{
if
(
entity
.
getSpawnEntry
()
!=
null
&&
!
visible
.
contains
(
entity
.
getSpawnEntry
()))
{
toRemove
.
add
(
entity
);
toRemove
.
add
(
entity
);
}
}
...
@@ -407,7 +407,7 @@ public class GenshinScene {
...
@@ -407,7 +407,7 @@ public class GenshinScene {
}
}
public
void
onPlayerDestroyGadget
(
int
entityId
)
{
public
void
onPlayerDestroyGadget
(
int
entityId
)
{
G
enshin
Entity
entity
=
getEntities
().
get
(
entityId
);
G
ame
Entity
entity
=
getEntities
().
get
(
entityId
);
if
(
entity
==
null
||
!(
entity
instanceof
EntityClientGadget
))
{
if
(
entity
==
null
||
!(
entity
instanceof
EntityClientGadget
))
{
return
;
return
;
...
@@ -430,20 +430,20 @@ public class GenshinScene {
...
@@ -430,20 +430,20 @@ public class GenshinScene {
// Broadcasting
// Broadcasting
public
void
broadcastPacket
(
Genshin
Packet
packet
)
{
public
void
broadcastPacket
(
Base
Packet
packet
)
{
// Send to all players - might have to check if player has been sent data packets
// Send to all players - might have to check if player has been sent data packets
for
(
Genshin
Player
player
:
this
.
getPlayers
())
{
for
(
Player
player
:
this
.
getPlayers
())
{
player
.
getSession
().
send
(
packet
);
player
.
getSession
().
send
(
packet
);
}
}
}
}
public
void
broadcastPacketToOthers
(
Genshin
Player
excludedPlayer
,
Genshin
Packet
packet
)
{
public
void
broadcastPacketToOthers
(
Player
excludedPlayer
,
Base
Packet
packet
)
{
// Optimization
// Optimization
if
(
this
.
getPlayerCount
()
==
1
&&
this
.
getPlayers
().
get
(
0
)
==
excludedPlayer
)
{
if
(
this
.
getPlayerCount
()
==
1
&&
this
.
getPlayers
().
get
(
0
)
==
excludedPlayer
)
{
return
;
return
;
}
}
// Send to all players - might have to check if player has been sent data packets
// Send to all players - might have to check if player has been sent data packets
for
(
Genshin
Player
player
:
this
.
getPlayers
())
{
for
(
Player
player
:
this
.
getPlayers
())
{
if
(
player
==
excludedPlayer
)
{
if
(
player
==
excludedPlayer
)
{
continue
;
continue
;
}
}
...
...
src/main/java/emu/grasscutter/game/TeamInfo.java
View file @
1c36f078
...
@@ -4,9 +4,9 @@ import java.util.ArrayList;
...
@@ -4,9 +4,9 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Entity
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
@Entity
@Entity
public
class
TeamInfo
{
public
class
TeamInfo
{
...
@@ -34,11 +34,11 @@ public class TeamInfo {
...
@@ -34,11 +34,11 @@ public class TeamInfo {
return
avatars
.
size
();
return
avatars
.
size
();
}
}
public
boolean
contains
(
Genshin
Avatar
avatar
)
{
public
boolean
contains
(
Avatar
avatar
)
{
return
getAvatars
().
contains
(
avatar
.
getAvatarId
());
return
getAvatars
().
contains
(
avatar
.
getAvatarId
());
}
}
public
boolean
addAvatar
(
Genshin
Avatar
avatar
)
{
public
boolean
addAvatar
(
Avatar
avatar
)
{
if
(
size
()
>=
Grasscutter
.
getConfig
().
getGameServerOptions
().
MaxAvatarsInTeam
||
contains
(
avatar
))
{
if
(
size
()
>=
Grasscutter
.
getConfig
().
getGameServerOptions
().
MaxAvatarsInTeam
||
contains
(
avatar
))
{
return
false
;
return
false
;
}
}
...
...
src/main/java/emu/grasscutter/game/TeamManager.java
View file @
1c36f078
...
@@ -10,16 +10,16 @@ import java.util.Set;
...
@@ -10,16 +10,16 @@ import java.util.Set;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Transient
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
...
@@ -44,7 +44,7 @@ import it.unimi.dsi.fastutil.ints.IntSet;
...
@@ -44,7 +44,7 @@ import it.unimi.dsi.fastutil.ints.IntSet;
@Entity
@Entity
public
class
TeamManager
{
public
class
TeamManager
{
@Transient
private
Genshin
Player
player
;
@Transient
private
Player
player
;
private
Map
<
Integer
,
TeamInfo
>
teams
;
private
Map
<
Integer
,
TeamInfo
>
teams
;
private
int
currentTeamIndex
;
private
int
currentTeamIndex
;
...
@@ -65,18 +65,18 @@ public class TeamManager {
...
@@ -65,18 +65,18 @@ public class TeamManager {
this
.
teamResonancesConfig
=
new
IntOpenHashSet
();
this
.
teamResonancesConfig
=
new
IntOpenHashSet
();
}
}
public
TeamManager
(
Genshin
Player
player
)
{
public
TeamManager
(
Player
player
)
{
this
();
this
();
this
.
player
=
player
;
this
.
player
=
player
;
this
.
teams
=
new
HashMap
<>();
this
.
teams
=
new
HashMap
<>();
this
.
currentTeamIndex
=
1
;
this
.
currentTeamIndex
=
1
;
for
(
int
i
=
1
;
i
<=
G
enshin
Constants
.
MAX_TEAMS
;
i
++)
{
for
(
int
i
=
1
;
i
<=
G
ame
Constants
.
MAX_TEAMS
;
i
++)
{
this
.
teams
.
put
(
i
,
new
TeamInfo
());
this
.
teams
.
put
(
i
,
new
TeamInfo
());
}
}
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
player
;
return
player
;
}
}
...
@@ -84,7 +84,7 @@ public class TeamManager {
...
@@ -84,7 +84,7 @@ public class TeamManager {
return
player
.
getWorld
();
return
player
.
getWorld
();
}
}
public
void
setPlayer
(
Genshin
Player
player
)
{
public
void
setPlayer
(
Player
player
)
{
this
.
player
=
player
;
this
.
player
=
player
;
}
}
...
@@ -207,7 +207,7 @@ public class TeamManager {
...
@@ -207,7 +207,7 @@ public class TeamManager {
}
}
}
}
public
void
updateTeamEntities
(
Genshin
Packet
responsePacket
)
{
public
void
updateTeamEntities
(
Base
Packet
responsePacket
)
{
// Sanity check - Should never happen
// Sanity check - Should never happen
if
(
this
.
getCurrentTeamInfo
().
getAvatars
().
size
()
<=
0
)
{
if
(
this
.
getCurrentTeamInfo
().
getAvatars
().
size
()
<=
0
)
{
return
;
return
;
...
@@ -287,9 +287,9 @@ public class TeamManager {
...
@@ -287,9 +287,9 @@ public class TeamManager {
}
}
// Set team data
// Set team data
LinkedHashSet
<
Genshin
Avatar
>
newTeam
=
new
LinkedHashSet
<>();
LinkedHashSet
<
Avatar
>
newTeam
=
new
LinkedHashSet
<>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Genshin
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
list
.
get
(
i
));
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
list
.
get
(
i
));
if
(
avatar
==
null
||
newTeam
.
contains
(
avatar
))
{
if
(
avatar
==
null
||
newTeam
.
contains
(
avatar
))
{
// Should never happen
// Should never happen
return
;
return
;
...
@@ -299,7 +299,7 @@ public class TeamManager {
...
@@ -299,7 +299,7 @@ public class TeamManager {
// Clear current team info and add avatars from our new team
// Clear current team info and add avatars from our new team
teamInfo
.
getAvatars
().
clear
();
teamInfo
.
getAvatars
().
clear
();
for
(
Genshin
Avatar
avatar
:
newTeam
)
{
for
(
Avatar
avatar
:
newTeam
)
{
teamInfo
.
addAvatar
(
avatar
);
teamInfo
.
addAvatar
(
avatar
);
}
}
...
@@ -323,9 +323,9 @@ public class TeamManager {
...
@@ -323,9 +323,9 @@ public class TeamManager {
TeamInfo
teamInfo
=
this
.
getMpTeam
();
TeamInfo
teamInfo
=
this
.
getMpTeam
();
// Set team data
// Set team data
LinkedHashSet
<
Genshin
Avatar
>
newTeam
=
new
LinkedHashSet
<>();
LinkedHashSet
<
Avatar
>
newTeam
=
new
LinkedHashSet
<>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Genshin
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
list
.
get
(
i
));
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
list
.
get
(
i
));
if
(
avatar
==
null
||
newTeam
.
contains
(
avatar
))
{
if
(
avatar
==
null
||
newTeam
.
contains
(
avatar
))
{
// Should never happen
// Should never happen
return
;
return
;
...
@@ -335,7 +335,7 @@ public class TeamManager {
...
@@ -335,7 +335,7 @@ public class TeamManager {
// Clear current team info and add avatars from our new team
// Clear current team info and add avatars from our new team
teamInfo
.
getAvatars
().
clear
();
teamInfo
.
getAvatars
().
clear
();
for
(
Genshin
Avatar
avatar
:
newTeam
)
{
for
(
Avatar
avatar
:
newTeam
)
{
teamInfo
.
addAvatar
(
avatar
);
teamInfo
.
addAvatar
(
avatar
);
}
}
...
@@ -437,7 +437,7 @@ public class TeamManager {
...
@@ -437,7 +437,7 @@ public class TeamManager {
getPlayer
().
sendPacket
(
new
PacketAvatarDieAnimationEndRsp
(
deadAvatar
.
getId
(),
0
));
getPlayer
().
sendPacket
(
new
PacketAvatarDieAnimationEndRsp
(
deadAvatar
.
getId
(),
0
));
}
}
public
boolean
reviveAvatar
(
Genshin
Avatar
avatar
)
{
public
boolean
reviveAvatar
(
Avatar
avatar
)
{
for
(
EntityAvatar
entity
:
getActiveTeam
())
{
for
(
EntityAvatar
entity
:
getActiveTeam
())
{
if
(
entity
.
getAvatar
()
==
avatar
)
{
if
(
entity
.
getAvatar
()
==
avatar
)
{
if
(
entity
.
isAlive
())
{
if
(
entity
.
isAlive
())
{
...
@@ -476,14 +476,14 @@ public class TeamManager {
...
@@ -476,14 +476,14 @@ public class TeamManager {
}
}
// Teleport player
// Teleport player
getPlayer
().
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
getPlayer
(),
EnterType
.
ENTER_SELF
,
EnterReason
.
Revival
,
3
,
G
enshin
Constants
.
START_POSITION
));
getPlayer
().
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
getPlayer
(),
EnterType
.
ENTER_SELF
,
EnterReason
.
Revival
,
3
,
G
ame
Constants
.
START_POSITION
));
// Set player position
// Set player position
player
.
setSceneId
(
3
);
player
.
setSceneId
(
3
);
player
.
getPos
().
set
(
G
enshin
Constants
.
START_POSITION
);
player
.
getPos
().
set
(
G
ame
Constants
.
START_POSITION
);
// Packets
// Packets
getPlayer
().
sendPacket
(
new
Genshin
Packet
(
PacketOpcodes
.
WorldPlayerReviveRsp
));
getPlayer
().
sendPacket
(
new
Base
Packet
(
PacketOpcodes
.
WorldPlayerReviveRsp
));
}
}
public
void
saveAvatars
()
{
public
void
saveAvatars
()
{
...
...
src/main/java/emu/grasscutter/game/World.java
View file @
1c36f078
...
@@ -8,19 +8,19 @@ import java.util.LinkedList;
...
@@ -8,19 +8,19 @@ import java.util.LinkedList;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
emu.grasscutter.game.entity.G
enshin
Entity
;
import
emu.grasscutter.game.entity.G
ame
Entity
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.def.SceneData
;
import
emu.grasscutter.data.def.SceneData
;
import
emu.grasscutter.game.
Genshin
Player.SceneLoadState
;
import
emu.grasscutter.game.Player.SceneLoadState
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityClientGadget
;
import
emu.grasscutter.game.entity.EntityClientGadget
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult
;
import
emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType
;
import
emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType
;
...
@@ -40,10 +40,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -40,10 +40,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMaps
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMaps
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
class
World
implements
Iterable
<
Genshin
Player
>
{
public
class
World
implements
Iterable
<
Player
>
{
private
final
Genshin
Player
owner
;
private
final
Player
owner
;
private
final
List
<
Genshin
Player
>
players
;
private
final
List
<
Player
>
players
;
private
final
Int2ObjectMap
<
Genshin
Scene
>
scenes
;
private
final
Int2ObjectMap
<
Scene
>
scenes
;
private
int
levelEntityId
;
private
int
levelEntityId
;
private
int
nextEntityId
=
0
;
private
int
nextEntityId
=
0
;
...
@@ -52,11 +52,11 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -52,11 +52,11 @@ public class World implements Iterable<GenshinPlayer> {
private
boolean
isMultiplayer
;
private
boolean
isMultiplayer
;
public
World
(
Genshin
Player
player
)
{
public
World
(
Player
player
)
{
this
(
player
,
false
);
this
(
player
,
false
);
}
}
public
World
(
Genshin
Player
player
,
boolean
isMultiplayer
)
{
public
World
(
Player
player
,
boolean
isMultiplayer
)
{
this
.
owner
=
player
;
this
.
owner
=
player
;
this
.
players
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
this
.
players
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
this
.
scenes
=
Int2ObjectMaps
.
synchronize
(
new
Int2ObjectOpenHashMap
<>());
this
.
scenes
=
Int2ObjectMaps
.
synchronize
(
new
Int2ObjectOpenHashMap
<>());
...
@@ -68,7 +68,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -68,7 +68,7 @@ public class World implements Iterable<GenshinPlayer> {
this
.
owner
.
getServer
().
registerWorld
(
this
);
this
.
owner
.
getServer
().
registerWorld
(
this
);
}
}
public
Genshin
Player
getHost
()
{
public
Player
getHost
()
{
return
owner
;
return
owner
;
}
}
...
@@ -95,25 +95,25 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -95,25 +95,25 @@ public class World implements Iterable<GenshinPlayer> {
this
.
worldLevel
=
worldLevel
;
this
.
worldLevel
=
worldLevel
;
}
}
public
List
<
Genshin
Player
>
getPlayers
()
{
public
List
<
Player
>
getPlayers
()
{
return
players
;
return
players
;
}
}
public
Int2ObjectMap
<
Genshin
Scene
>
getScenes
()
{
public
Int2ObjectMap
<
Scene
>
getScenes
()
{
return
this
.
scenes
;
return
this
.
scenes
;
}
}
public
Genshin
Scene
getSceneById
(
int
sceneId
)
{
public
Scene
getSceneById
(
int
sceneId
)
{
// Get scene normally
// Get scene normally
Genshin
Scene
scene
=
getScenes
().
get
(
sceneId
);
Scene
scene
=
getScenes
().
get
(
sceneId
);
if
(
scene
!=
null
)
{
if
(
scene
!=
null
)
{
return
scene
;
return
scene
;
}
}
// Create scene from scene data if it doesnt exist
// Create scene from scene data if it doesnt exist
SceneData
sceneData
=
G
enshin
Data
.
getSceneDataMap
().
get
(
sceneId
);
SceneData
sceneData
=
G
ame
Data
.
getSceneDataMap
().
get
(
sceneId
);
if
(
sceneData
!=
null
)
{
if
(
sceneData
!=
null
)
{
scene
=
new
Genshin
Scene
(
this
,
sceneData
);
scene
=
new
Scene
(
this
,
sceneData
);
this
.
registerScene
(
scene
);
this
.
registerScene
(
scene
);
return
scene
;
return
scene
;
}
}
...
@@ -133,7 +133,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -133,7 +133,7 @@ public class World implements Iterable<GenshinPlayer> {
return
(
idType
.
getId
()
<<
24
)
+
++
this
.
nextEntityId
;
return
(
idType
.
getId
()
<<
24
)
+
++
this
.
nextEntityId
;
}
}
public
synchronized
void
addPlayer
(
Genshin
Player
player
)
{
public
synchronized
void
addPlayer
(
Player
player
)
{
// Check if player already in
// Check if player already in
if
(
getPlayers
().
contains
(
player
))
{
if
(
getPlayers
().
contains
(
player
))
{
return
;
return
;
...
@@ -159,7 +159,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -159,7 +159,7 @@ public class World implements Iterable<GenshinPlayer> {
}
}
// Add to scene
// Add to scene
Genshin
Scene
scene
=
this
.
getSceneById
(
player
.
getSceneId
());
Scene
scene
=
this
.
getSceneById
(
player
.
getSceneId
());
scene
.
addPlayer
(
player
);
scene
.
addPlayer
(
player
);
// Info packet for other players
// Info packet for other players
...
@@ -168,7 +168,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -168,7 +168,7 @@ public class World implements Iterable<GenshinPlayer> {
}
}
}
}
public
synchronized
void
removePlayer
(
Genshin
Player
player
)
{
public
synchronized
void
removePlayer
(
Player
player
)
{
// Remove team entities
// Remove team entities
player
.
sendPacket
(
player
.
sendPacket
(
new
PacketDelTeamEntityNotify
(
new
PacketDelTeamEntityNotify
(
...
@@ -182,7 +182,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -182,7 +182,7 @@ public class World implements Iterable<GenshinPlayer> {
player
.
setWorld
(
null
);
player
.
setWorld
(
null
);
// Remove from scene
// Remove from scene
Genshin
Scene
scene
=
this
.
getSceneById
(
player
.
getSceneId
());
Scene
scene
=
this
.
getSceneById
(
player
.
getSceneId
());
scene
.
removePlayer
(
player
);
scene
.
removePlayer
(
player
);
// Info packet for other players
// Info packet for other players
...
@@ -192,8 +192,8 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -192,8 +192,8 @@ public class World implements Iterable<GenshinPlayer> {
// Disband world if host leaves
// Disband world if host leaves
if
(
getHost
()
==
player
)
{
if
(
getHost
()
==
player
)
{
List
<
Genshin
Player
>
kicked
=
new
ArrayList
<>(
this
.
getPlayers
());
List
<
Player
>
kicked
=
new
ArrayList
<>(
this
.
getPlayers
());
for
(
Genshin
Player
victim
:
kicked
)
{
for
(
Player
victim
:
kicked
)
{
World
world
=
new
World
(
victim
);
World
world
=
new
World
(
victim
);
world
.
addPlayer
(
victim
);
world
.
addPlayer
(
victim
);
...
@@ -202,20 +202,20 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -202,20 +202,20 @@ public class World implements Iterable<GenshinPlayer> {
}
}
}
}
public
void
registerScene
(
Genshin
Scene
scene
)
{
public
void
registerScene
(
Scene
scene
)
{
this
.
getScenes
().
put
(
scene
.
getId
(),
scene
);
this
.
getScenes
().
put
(
scene
.
getId
(),
scene
);
}
}
public
void
deregisterScene
(
Genshin
Scene
scene
)
{
public
void
deregisterScene
(
Scene
scene
)
{
this
.
getScenes
().
remove
(
scene
.
getId
());
this
.
getScenes
().
remove
(
scene
.
getId
());
}
}
public
boolean
transferPlayerToScene
(
Genshin
Player
player
,
int
sceneId
,
Position
pos
)
{
public
boolean
transferPlayerToScene
(
Player
player
,
int
sceneId
,
Position
pos
)
{
if
(
G
enshin
Data
.
getSceneDataMap
().
get
(
sceneId
)
==
null
)
{
if
(
G
ame
Data
.
getSceneDataMap
().
get
(
sceneId
)
==
null
)
{
return
false
;
return
false
;
}
}
Genshin
Scene
oldScene
=
null
;
Scene
oldScene
=
null
;
if
(
player
.
getScene
()
!=
null
)
{
if
(
player
.
getScene
()
!=
null
)
{
oldScene
=
player
.
getScene
();
oldScene
=
player
.
getScene
();
...
@@ -228,7 +228,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -228,7 +228,7 @@ public class World implements Iterable<GenshinPlayer> {
oldScene
.
removePlayer
(
player
);
oldScene
.
removePlayer
(
player
);
}
}
Genshin
Scene
newScene
=
this
.
getSceneById
(
sceneId
);
Scene
newScene
=
this
.
getSceneById
(
sceneId
);
newScene
.
addPlayer
(
player
);
newScene
.
addPlayer
(
player
);
player
.
getPos
().
set
(
pos
);
player
.
getPos
().
set
(
pos
);
...
@@ -245,8 +245,8 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -245,8 +245,8 @@ public class World implements Iterable<GenshinPlayer> {
return
true
;
return
true
;
}
}
private
void
updatePlayerInfos
(
Genshin
Player
paramPlayer
)
{
private
void
updatePlayerInfos
(
Player
paramPlayer
)
{
for
(
Genshin
Player
player
:
getPlayers
())
{
for
(
Player
player
:
getPlayers
())
{
// Dont send packets if player is loading in and filter out joining player
// Dont send packets if player is loading in and filter out joining player
if
(!
player
.
hasSentAvatarDataNotify
()
||
player
.
getSceneLoadState
().
getValue
()
<
SceneLoadState
.
INIT
.
getValue
()
||
player
==
paramPlayer
)
{
if
(!
player
.
hasSentAvatarDataNotify
()
||
player
.
getSceneLoadState
().
getValue
()
<
SceneLoadState
.
INIT
.
getValue
()
||
player
==
paramPlayer
)
{
continue
;
continue
;
...
@@ -269,15 +269,15 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -269,15 +269,15 @@ public class World implements Iterable<GenshinPlayer> {
}
}
}
}
public
void
broadcastPacket
(
Genshin
Packet
packet
)
{
public
void
broadcastPacket
(
Base
Packet
packet
)
{
// Send to all players - might have to check if player has been sent data packets
// Send to all players - might have to check if player has been sent data packets
for
(
Genshin
Player
player
:
this
.
getPlayers
())
{
for
(
Player
player
:
this
.
getPlayers
())
{
player
.
getSession
().
send
(
packet
);
player
.
getSession
().
send
(
packet
);
}
}
}
}
public
void
onTick
()
{
public
void
onTick
()
{
for
(
Genshin
Scene
scene
:
this
.
getScenes
().
values
())
{
for
(
Scene
scene
:
this
.
getScenes
().
values
())
{
scene
.
onTick
();
scene
.
onTick
();
}
}
}
}
...
@@ -287,7 +287,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -287,7 +287,7 @@ public class World implements Iterable<GenshinPlayer> {
}
}
@Override
@Override
public
Iterator
<
Genshin
Player
>
iterator
()
{
public
Iterator
<
Player
>
iterator
()
{
return
getPlayers
().
iterator
();
return
getPlayers
().
iterator
();
}
}
}
}
src/main/java/emu/grasscutter/game/avatar/
Genshin
Avatar.java
→
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
1c36f078
...
@@ -16,7 +16,7 @@ import dev.morphia.annotations.PostLoad;
...
@@ -16,7 +16,7 @@ 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.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarData
;
...
@@ -35,10 +35,10 @@ import emu.grasscutter.data.def.WeaponPromoteData;
...
@@ -35,10 +35,10 @@ import emu.grasscutter.data.def.WeaponPromoteData;
import
emu.grasscutter.data.def.ItemData.WeaponProperty
;
import
emu.grasscutter.data.def.ItemData.WeaponProperty
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FetterState
;
import
emu.grasscutter.game.props.FetterState
;
...
@@ -57,11 +57,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -57,11 +57,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
@Entity
(
value
=
"avatars"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"avatars"
,
useDiscriminator
=
false
)
public
class
Genshin
Avatar
{
public
class
Avatar
{
@Id
private
ObjectId
id
;
@Id
private
ObjectId
id
;
@Indexed
private
int
ownerId
;
// Id of player that this avatar belongs to
@Indexed
private
int
ownerId
;
// Id of player that this avatar belongs to
@Transient
private
Genshin
Player
owner
;
@Transient
private
Player
owner
;
@Transient
private
AvatarData
data
;
@Transient
private
AvatarData
data
;
@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
...
@@ -73,7 +73,7 @@ public class GenshinAvatar {
...
@@ -73,7 +73,7 @@ public class GenshinAvatar {
private
int
satiationPenalty
;
// ?
private
int
satiationPenalty
;
// ?
private
float
currentHp
;
private
float
currentHp
;
@Transient
private
final
Int2ObjectMap
<
G
enshin
Item
>
equips
;
@Transient
private
final
Int2ObjectMap
<
G
ame
Item
>
equips
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
Set
<
String
>
extraAbilityEmbryos
;
@Transient
private
Set
<
String
>
extraAbilityEmbryos
;
...
@@ -96,21 +96,21 @@ public class GenshinAvatar {
...
@@ -96,21 +96,21 @@ public class GenshinAvatar {
private
int
nameCardRewardId
;
private
int
nameCardRewardId
;
private
int
nameCardId
;
private
int
nameCardId
;
public
Genshin
Avatar
()
{
public
Avatar
()
{
// Morhpia only!
// 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
<>();
this
.
proudSkillBonusMap
=
new
HashMap
<>();
this
.
proudSkillBonusMap
=
new
HashMap
<>();
this
.
fetters
=
new
ArrayList
<>();
// TODO Move to
genshin
avatar
this
.
fetters
=
new
ArrayList
<>();
// TODO Move to avatar
}
}
// On creation
// On creation
public
Genshin
Avatar
(
int
avatarId
)
{
public
Avatar
(
int
avatarId
)
{
this
(
G
enshin
Data
.
getAvatarDataMap
().
get
(
avatarId
));
this
(
G
ame
Data
.
getAvatarDataMap
().
get
(
avatarId
));
}
}
public
Genshin
Avatar
(
AvatarData
data
)
{
public
Avatar
(
AvatarData
data
)
{
this
();
this
();
this
.
avatarId
=
data
.
getId
();
this
.
avatarId
=
data
.
getId
();
this
.
nameCardRewardId
=
data
.
getNameCardRewardId
();
this
.
nameCardRewardId
=
data
.
getNameCardRewardId
();
...
@@ -143,7 +143,7 @@ public class GenshinAvatar {
...
@@ -143,7 +143,7 @@ public class GenshinAvatar {
this
.
onLoad
();
this
.
onLoad
();
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
this
.
owner
;
return
this
.
owner
;
}
}
...
@@ -163,10 +163,10 @@ public class GenshinAvatar {
...
@@ -163,10 +163,10 @@ public class GenshinAvatar {
return
ownerId
;
return
ownerId
;
}
}
public
void
setOwner
(
Genshin
Player
player
)
{
public
void
setOwner
(
Player
player
)
{
this
.
owner
=
player
;
this
.
owner
=
player
;
this
.
ownerId
=
player
.
getUid
();
this
.
ownerId
=
player
.
getUid
();
this
.
guid
=
player
.
getNextG
enshin
Guid
();
this
.
guid
=
player
.
getNextG
ame
Guid
();
}
}
public
int
getSatiation
()
{
public
int
getSatiation
()
{
...
@@ -229,19 +229,19 @@ public class GenshinAvatar {
...
@@ -229,19 +229,19 @@ public class GenshinAvatar {
this
.
promoteLevel
=
promoteLevel
;
this
.
promoteLevel
=
promoteLevel
;
}
}
public
Int2ObjectMap
<
G
enshin
Item
>
getEquips
()
{
public
Int2ObjectMap
<
G
ame
Item
>
getEquips
()
{
return
equips
;
return
equips
;
}
}
public
G
enshin
Item
getEquipBySlot
(
EquipType
slot
)
{
public
G
ame
Item
getEquipBySlot
(
EquipType
slot
)
{
return
this
.
getEquips
().
get
(
slot
.
getValue
());
return
this
.
getEquips
().
get
(
slot
.
getValue
());
}
}
private
G
enshin
Item
getEquipBySlot
(
int
slotId
)
{
private
G
ame
Item
getEquipBySlot
(
int
slotId
)
{
return
this
.
getEquips
().
get
(
slotId
);
return
this
.
getEquips
().
get
(
slotId
);
}
}
public
G
enshin
Item
getWeapon
()
{
public
G
ame
Item
getWeapon
()
{
return
this
.
getEquipBySlot
(
EquipType
.
EQUIP_WEAPON
);
return
this
.
getEquipBySlot
(
EquipType
.
EQUIP_WEAPON
);
}
}
...
@@ -270,7 +270,7 @@ public class GenshinAvatar {
...
@@ -270,7 +270,7 @@ public class GenshinAvatar {
}
}
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
if
(
G
enshin
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
if
(
G
ame
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
this
.
getProudSkillList
().
add
(
proudSkillId
);
this
.
getProudSkillList
().
add
(
proudSkillId
);
}
}
}
}
...
@@ -385,7 +385,7 @@ public class GenshinAvatar {
...
@@ -385,7 +385,7 @@ public class GenshinAvatar {
return
bornTime
;
return
bornTime
;
}
}
public
boolean
equipItem
(
G
enshin
Item
item
,
boolean
shouldRecalc
)
{
public
boolean
equipItem
(
G
ame
Item
item
,
boolean
shouldRecalc
)
{
EquipType
itemEquipType
=
item
.
getItemData
().
getEquipType
();
EquipType
itemEquipType
=
item
.
getItemData
().
getEquipType
();
if
(
itemEquipType
==
EquipType
.
EQUIP_NONE
)
{
if
(
itemEquipType
==
EquipType
.
EQUIP_NONE
)
{
return
false
;
return
false
;
...
@@ -416,7 +416,7 @@ public class GenshinAvatar {
...
@@ -416,7 +416,7 @@ public class GenshinAvatar {
}
}
public
boolean
unequipItem
(
EquipType
slot
)
{
public
boolean
unequipItem
(
EquipType
slot
)
{
G
enshin
Item
item
=
getEquips
().
remove
(
slot
.
getValue
());
G
ame
Item
item
=
getEquips
().
remove
(
slot
.
getValue
());
if
(
item
!=
null
)
{
if
(
item
!=
null
)
{
item
.
setEquipCharacter
(
0
);
item
.
setEquipCharacter
(
0
);
...
@@ -434,7 +434,7 @@ public class GenshinAvatar {
...
@@ -434,7 +434,7 @@ public class GenshinAvatar {
public
void
recalcStats
(
boolean
forceSendAbilityChange
)
{
public
void
recalcStats
(
boolean
forceSendAbilityChange
)
{
// Setup
// Setup
AvatarData
data
=
this
.
getAvatarData
();
AvatarData
data
=
this
.
getAvatarData
();
AvatarPromoteData
promoteData
=
G
enshin
Data
.
getAvatarPromoteData
(
data
.
getAvatarPromoteId
(),
this
.
getPromoteLevel
());
AvatarPromoteData
promoteData
=
G
ame
Data
.
getAvatarPromoteData
(
data
.
getAvatarPromoteId
(),
this
.
getPromoteLevel
());
Int2IntOpenHashMap
setMap
=
new
Int2IntOpenHashMap
();
Int2IntOpenHashMap
setMap
=
new
Int2IntOpenHashMap
();
// Extra ability embryos
// Extra ability embryos
...
@@ -476,21 +476,21 @@ public class GenshinAvatar {
...
@@ -476,21 +476,21 @@ public class GenshinAvatar {
// Artifacts
// Artifacts
for
(
int
slotId
=
1
;
slotId
<=
5
;
slotId
++)
{
for
(
int
slotId
=
1
;
slotId
<=
5
;
slotId
++)
{
// Get artifact
// Get artifact
G
enshin
Item
equip
=
this
.
getEquipBySlot
(
slotId
);
G
ame
Item
equip
=
this
.
getEquipBySlot
(
slotId
);
if
(
equip
==
null
)
{
if
(
equip
==
null
)
{
continue
;
continue
;
}
}
// Artifact main stat
// Artifact main stat
ReliquaryMainPropData
mainPropData
=
G
enshin
Data
.
getReliquaryMainPropDataMap
().
get
(
equip
.
getMainPropId
());
ReliquaryMainPropData
mainPropData
=
G
ame
Data
.
getReliquaryMainPropDataMap
().
get
(
equip
.
getMainPropId
());
if
(
mainPropData
!=
null
)
{
if
(
mainPropData
!=
null
)
{
ReliquaryLevelData
levelData
=
G
enshin
Data
.
getRelicLevelData
(
equip
.
getItemData
().
getRankLevel
(),
equip
.
getLevel
());
ReliquaryLevelData
levelData
=
G
ame
Data
.
getRelicLevelData
(
equip
.
getItemData
().
getRankLevel
(),
equip
.
getLevel
());
if
(
levelData
!=
null
)
{
if
(
levelData
!=
null
)
{
this
.
addFightProperty
(
mainPropData
.
getFightProp
(),
levelData
.
getPropValue
(
mainPropData
.
getFightProp
()));
this
.
addFightProperty
(
mainPropData
.
getFightProp
(),
levelData
.
getPropValue
(
mainPropData
.
getFightProp
()));
}
}
}
}
// Artifact sub stats
// Artifact sub stats
for
(
int
appendPropId
:
equip
.
getAppendPropIdList
())
{
for
(
int
appendPropId
:
equip
.
getAppendPropIdList
())
{
ReliquaryAffixData
affixData
=
G
enshin
Data
.
getReliquaryAffixDataMap
().
get
(
appendPropId
);
ReliquaryAffixData
affixData
=
G
ame
Data
.
getReliquaryAffixDataMap
().
get
(
appendPropId
);
if
(
affixData
!=
null
)
{
if
(
affixData
!=
null
)
{
this
.
addFightProperty
(
affixData
.
getFightProp
(),
affixData
.
getPropValue
());
this
.
addFightProperty
(
affixData
.
getFightProp
(),
affixData
.
getPropValue
());
}
}
...
@@ -503,7 +503,7 @@ public class GenshinAvatar {
...
@@ -503,7 +503,7 @@ public class GenshinAvatar {
// Set stuff
// Set stuff
for
(
Int2IntOpenHashMap
.
Entry
e
:
setMap
.
int2IntEntrySet
())
{
for
(
Int2IntOpenHashMap
.
Entry
e
:
setMap
.
int2IntEntrySet
())
{
ReliquarySetData
setData
=
G
enshin
Data
.
getReliquarySetDataMap
().
get
(
e
.
getIntKey
());
ReliquarySetData
setData
=
G
ame
Data
.
getReliquarySetDataMap
().
get
(
e
.
getIntKey
());
if
(
setData
==
null
)
{
if
(
setData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -516,7 +516,7 @@ public class GenshinAvatar {
...
@@ -516,7 +516,7 @@ public class GenshinAvatar {
if
(
amount
>=
setData
.
getSetNeedNum
()[
setIndex
])
{
if
(
amount
>=
setData
.
getSetNeedNum
()[
setIndex
])
{
int
affixId
=
(
setData
.
getEquipAffixId
()
*
10
)
+
setIndex
;
int
affixId
=
(
setData
.
getEquipAffixId
()
*
10
)
+
setIndex
;
EquipAffixData
affix
=
G
enshin
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
EquipAffixData
affix
=
G
ame
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
if
(
affix
==
null
)
{
if
(
affix
==
null
)
{
continue
;
continue
;
}
}
...
@@ -535,17 +535,17 @@ public class GenshinAvatar {
...
@@ -535,17 +535,17 @@ public class GenshinAvatar {
}
}
// Weapon
// Weapon
G
enshin
Item
weapon
=
this
.
getWeapon
();
G
ame
Item
weapon
=
this
.
getWeapon
();
if
(
weapon
!=
null
)
{
if
(
weapon
!=
null
)
{
// Add stats
// Add stats
WeaponCurveData
curveData
=
G
enshin
Data
.
getWeaponCurveDataMap
().
get
(
weapon
.
getLevel
());
WeaponCurveData
curveData
=
G
ame
Data
.
getWeaponCurveDataMap
().
get
(
weapon
.
getLevel
());
if
(
curveData
!=
null
)
{
if
(
curveData
!=
null
)
{
for
(
WeaponProperty
weaponProperty
:
weapon
.
getItemData
().
getWeaponProperties
())
{
for
(
WeaponProperty
weaponProperty
:
weapon
.
getItemData
().
getWeaponProperties
())
{
this
.
addFightProperty
(
weaponProperty
.
getFightProp
(),
weaponProperty
.
getInitValue
()
*
curveData
.
getMultByProp
(
weaponProperty
.
getType
()));
this
.
addFightProperty
(
weaponProperty
.
getFightProp
(),
weaponProperty
.
getInitValue
()
*
curveData
.
getMultByProp
(
weaponProperty
.
getType
()));
}
}
}
}
// Weapon promotion stats
// Weapon promotion stats
WeaponPromoteData
wepPromoteData
=
G
enshin
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
WeaponPromoteData
wepPromoteData
=
G
ame
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
if
(
wepPromoteData
!=
null
)
{
if
(
wepPromoteData
!=
null
)
{
for
(
FightPropData
prop
:
wepPromoteData
.
getAddProps
())
{
for
(
FightPropData
prop
:
wepPromoteData
.
getAddProps
())
{
if
(
prop
.
getValue
()
==
0
f
||
prop
.
getProp
()
==
null
)
{
if
(
prop
.
getValue
()
==
0
f
||
prop
.
getProp
()
==
null
)
{
...
@@ -563,7 +563,7 @@ public class GenshinAvatar {
...
@@ -563,7 +563,7 @@ public class GenshinAvatar {
}
}
// Calculate affix id
// Calculate affix id
int
affixId
=
(
af
*
10
)
+
weapon
.
getRefinement
();
int
affixId
=
(
af
*
10
)
+
weapon
.
getRefinement
();
EquipAffixData
affix
=
G
enshin
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
EquipAffixData
affix
=
G
ame
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
if
(
affix
==
null
)
{
if
(
affix
==
null
)
{
continue
;
continue
;
}
}
...
@@ -580,7 +580,7 @@ public class GenshinAvatar {
...
@@ -580,7 +580,7 @@ public class GenshinAvatar {
}
}
// Add proud skills and unlock them if needed
// Add proud skills and unlock them if needed
AvatarSkillDepotData
skillDepot
=
G
enshin
Data
.
getAvatarSkillDepotDataMap
().
get
(
this
.
getSkillDepotId
());
AvatarSkillDepotData
skillDepot
=
G
ame
Data
.
getAvatarSkillDepotDataMap
().
get
(
this
.
getSkillDepotId
());
this
.
getProudSkillList
().
clear
();
this
.
getProudSkillList
().
clear
();
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
if
(
openData
.
getProudSkillGroupId
()
==
0
)
{
if
(
openData
.
getProudSkillGroupId
()
==
0
)
{
...
@@ -588,7 +588,7 @@ public class GenshinAvatar {
...
@@ -588,7 +588,7 @@ public class GenshinAvatar {
}
}
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
if
(
G
enshin
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
if
(
G
ame
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
this
.
getProudSkillList
().
add
(
proudSkillId
);
this
.
getProudSkillList
().
add
(
proudSkillId
);
}
}
}
}
...
@@ -596,7 +596,7 @@ public class GenshinAvatar {
...
@@ -596,7 +596,7 @@ public class GenshinAvatar {
// Proud skills
// Proud skills
for
(
int
proudSkillId
:
this
.
getProudSkillList
())
{
for
(
int
proudSkillId
:
this
.
getProudSkillList
())
{
ProudSkillData
proudSkillData
=
G
enshin
Data
.
getProudSkillDataMap
().
get
(
proudSkillId
);
ProudSkillData
proudSkillData
=
G
ame
Data
.
getProudSkillDataMap
().
get
(
proudSkillId
);
if
(
proudSkillData
==
null
)
{
if
(
proudSkillData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -613,7 +613,7 @@ public class GenshinAvatar {
...
@@ -613,7 +613,7 @@ public class GenshinAvatar {
// Constellations
// Constellations
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
AvatarTalentData
avatarTalentData
=
G
enshin
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
AvatarTalentData
avatarTalentData
=
G
ame
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
if
(
avatarTalentData
==
null
)
{
if
(
avatarTalentData
==
null
)
{
return
;
return
;
}
}
...
@@ -657,7 +657,7 @@ public class GenshinAvatar {
...
@@ -657,7 +657,7 @@ public class GenshinAvatar {
return
;
return
;
}
}
OpenConfigEntry
entry
=
G
enshin
Data
.
getOpenConfigEntries
().
get
(
openConfig
);
OpenConfigEntry
entry
=
G
ame
Data
.
getOpenConfigEntries
().
get
(
openConfig
);
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
if
(
forceAdd
)
{
if
(
forceAdd
)
{
// Add config string to ability skill list anyways
// Add config string to ability skill list anyways
...
@@ -684,14 +684,14 @@ public class GenshinAvatar {
...
@@ -684,14 +684,14 @@ public class GenshinAvatar {
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
AvatarTalentData
avatarTalentData
=
G
enshin
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
AvatarTalentData
avatarTalentData
=
G
ame
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
if
(
avatarTalentData
==
null
||
avatarTalentData
.
getOpenConfig
()
==
null
||
avatarTalentData
.
getOpenConfig
().
length
()
==
0
)
{
if
(
avatarTalentData
==
null
||
avatarTalentData
.
getOpenConfig
()
==
null
||
avatarTalentData
.
getOpenConfig
().
length
()
==
0
)
{
continue
;
continue
;
}
}
// Get open config to find which skill should be boosted
// Get open config to find which skill should be boosted
OpenConfigEntry
entry
=
G
enshin
Data
.
getOpenConfigEntries
().
get
(
avatarTalentData
.
getOpenConfig
());
OpenConfigEntry
entry
=
G
ame
Data
.
getOpenConfigEntries
().
get
(
avatarTalentData
.
getOpenConfig
());
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
continue
;
continue
;
}
}
...
@@ -712,7 +712,7 @@ public class GenshinAvatar {
...
@@ -712,7 +712,7 @@ public class GenshinAvatar {
}
}
// Get proud skill group id
// Get proud skill group id
AvatarSkillData
skillData
=
G
enshin
Data
.
getAvatarSkillDataMap
().
get
(
skillId
);
AvatarSkillData
skillData
=
G
ame
Data
.
getAvatarSkillDataMap
().
get
(
skillId
);
if
(
skillData
==
null
)
{
if
(
skillData
==
null
)
{
continue
;
continue
;
...
@@ -785,7 +785,7 @@ public class GenshinAvatar {
...
@@ -785,7 +785,7 @@ public class GenshinAvatar {
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setCostumeId
(
this
.
getCostume
());
.
setCostumeId
(
this
.
getCostume
());
for
(
G
enshin
Item
item
:
this
.
getEquips
().
values
())
{
for
(
G
ame
Item
item
:
this
.
getEquips
().
values
())
{
avatarInfo
.
addEquipGuidList
(
item
.
getGuid
());
avatarInfo
.
addEquipGuidList
(
item
.
getGuid
());
}
}
...
...
src/main/java/emu/grasscutter/game/avatar/AvatarProfileData.java
View file @
1c36f078
...
@@ -7,7 +7,7 @@ public class AvatarProfileData {
...
@@ -7,7 +7,7 @@ public class AvatarProfileData {
private
int
avatarId
;
private
int
avatarId
;
private
int
level
;
private
int
level
;
public
AvatarProfileData
(
Genshin
Avatar
avatar
)
{
public
AvatarProfileData
(
Avatar
avatar
)
{
this
.
update
(
avatar
);
this
.
update
(
avatar
);
}
}
...
@@ -19,7 +19,7 @@ public class AvatarProfileData {
...
@@ -19,7 +19,7 @@ public class AvatarProfileData {
return
level
;
return
level
;
}
}
public
void
update
(
Genshin
Avatar
avatar
)
{
public
void
update
(
Avatar
avatar
)
{
this
.
avatarId
=
avatar
.
getAvatarId
();
this
.
avatarId
=
avatar
.
getAvatarId
();
this
.
level
=
avatar
.
getLevel
();
this
.
level
=
avatar
.
getLevel
();
}
}
...
...
Prev
1
2
3
4
5
6
7
8
…
14
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