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
e6402c31
Commit
e6402c31
authored
Apr 22, 2022
by
memetrollsXD
Browse files
Merge branch 'stable' into development
parents
d5d90564
1dfe8733
Changes
107
Expand all
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java
View file @
e6402c31
package
emu.grasscutter.game.avatar
;
package
emu.grasscutter.game.avatar
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -13,6 +15,7 @@ import dev.morphia.annotations.Indexed;
...
@@ -13,6 +15,7 @@ import dev.morphia.annotations.Indexed;
import
dev.morphia.annotations.PostLoad
;
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.data.GenshinData
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
...
@@ -38,10 +41,13 @@ import emu.grasscutter.game.inventory.EquipType;
...
@@ -38,10 +41,13 @@ import emu.grasscutter.game.inventory.EquipType;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GenshinItem
;
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.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo
;
import
emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo
;
import
emu.grasscutter.net.proto.FetterDataOuterClass.FetterData
;
import
emu.grasscutter.net.proto.AvatarInfoOuterClass.AvatarInfo
;
import
emu.grasscutter.net.proto.AvatarInfoOuterClass.AvatarInfo
;
import
emu.grasscutter.server.packet.send.PacketAbilityChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropNotify
;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.ProtoHelper
;
...
@@ -69,7 +75,9 @@ public class GenshinAvatar {
...
@@ -69,7 +75,9 @@ public class GenshinAvatar {
@Transient
private
final
Int2ObjectMap
<
GenshinItem
>
equips
;
@Transient
private
final
Int2ObjectMap
<
GenshinItem
>
equips
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
final
Set
<
String
>
bonusAbilityList
;
@Transient
private
Set
<
String
>
extraAbilityEmbryos
;
private
List
<
Integer
>
fetters
;
private
Map
<
Integer
,
Integer
>
skillLevelMap
;
// Talent levels
private
Map
<
Integer
,
Integer
>
skillLevelMap
;
// Talent levels
private
Map
<
Integer
,
Integer
>
proudSkillBonusMap
;
// Talent bonus levels (from const)
private
Map
<
Integer
,
Integer
>
proudSkillBonusMap
;
// Talent bonus levels (from const)
...
@@ -86,8 +94,9 @@ public class GenshinAvatar {
...
@@ -86,8 +94,9 @@ public class GenshinAvatar {
// Morhpia only!
// Morhpia only!
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
bonusAbilityList
=
new
HashSet
<>();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
this
.
proudSkillBonusMap
=
new
HashMap
<>();
// TODO Move to genshin avatar
this
.
proudSkillBonusMap
=
new
HashMap
<>();
this
.
fetters
=
new
ArrayList
<>();
// TODO Move to genshin avatar
}
}
// On creation
// On creation
...
@@ -260,8 +269,16 @@ public class GenshinAvatar {
...
@@ -260,8 +269,16 @@ public class GenshinAvatar {
return
proudSkillBonusMap
;
return
proudSkillBonusMap
;
}
}
public
Set
<
String
>
getBonusAbilityList
()
{
public
Set
<
String
>
getExtraAbilityEmbryos
()
{
return
bonusAbilityList
;
return
extraAbilityEmbryos
;
}
public
void
setFetterList
(
List
<
Integer
>
fetterList
)
{
this
.
fetters
=
fetterList
;
}
public
List
<
Integer
>
getFetterList
()
{
return
fetters
;
}
}
public
float
getCurrentHp
()
{
public
float
getCurrentHp
()
{
...
@@ -347,14 +364,14 @@ public class GenshinAvatar {
...
@@ -347,14 +364,14 @@ public class GenshinAvatar {
item
.
setEquipCharacter
(
this
.
getAvatarId
());
item
.
setEquipCharacter
(
this
.
getAvatarId
());
item
.
save
();
item
.
save
();
if
(
shouldRecalc
)
{
this
.
recalcStats
();
}
if
(
this
.
getPlayer
().
hasSentAvatarDataNotify
())
{
if
(
this
.
getPlayer
().
hasSentAvatarDataNotify
())
{
this
.
getPlayer
().
sendPacket
(
new
PacketAvatarEquipChangeNotify
(
this
,
item
));
this
.
getPlayer
().
sendPacket
(
new
PacketAvatarEquipChangeNotify
(
this
,
item
));
}
}
if
(
shouldRecalc
)
{
this
.
recalcStats
();
}
return
true
;
return
true
;
}
}
...
@@ -371,11 +388,21 @@ public class GenshinAvatar {
...
@@ -371,11 +388,21 @@ public class GenshinAvatar {
}
}
public
void
recalcStats
()
{
public
void
recalcStats
()
{
recalcStats
(
false
);
}
public
void
recalcStats
(
boolean
forceSendAbilityChange
)
{
// Setup
// Setup
AvatarData
data
=
this
.
getAvatarData
();
AvatarData
data
=
this
.
getAvatarData
();
AvatarPromoteData
promoteData
=
GenshinData
.
getAvatarPromoteData
(
data
.
getAvatarPromoteId
(),
this
.
getPromoteLevel
());
AvatarPromoteData
promoteData
=
GenshinData
.
getAvatarPromoteData
(
data
.
getAvatarPromoteId
(),
this
.
getPromoteLevel
());
Int2IntOpenHashMap
setMap
=
new
Int2IntOpenHashMap
();
Int2IntOpenHashMap
setMap
=
new
Int2IntOpenHashMap
();
this
.
getBonusAbilityList
().
clear
();
// Extra ability embryos
Set
<
String
>
prevExtraAbilityEmbryos
=
this
.
getExtraAbilityEmbryos
();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
// Fetters
this
.
setFetterList
(
data
.
getFetters
());
// 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
);
...
@@ -458,7 +485,7 @@ public class GenshinAvatar {
...
@@ -458,7 +485,7 @@ public class GenshinAvatar {
}
}
// Add any skill strings from this affix
// Add any skill strings from this affix
this
.
addToAbility
List
(
affix
.
getOpenConfig
(),
true
);
this
.
addTo
Extra
Ability
Embryos
(
affix
.
getOpenConfig
(),
true
);
}
else
{
}
else
{
break
;
break
;
}
}
...
@@ -505,7 +532,7 @@ public class GenshinAvatar {
...
@@ -505,7 +532,7 @@ public class GenshinAvatar {
}
}
// Add any skill strings from this affix
// Add any skill strings from this affix
this
.
addToAbility
List
(
affix
.
getOpenConfig
(),
true
);
this
.
addTo
Extra
Ability
Embryos
(
affix
.
getOpenConfig
(),
true
);
}
}
}
}
}
}
...
@@ -538,7 +565,7 @@ public class GenshinAvatar {
...
@@ -538,7 +565,7 @@ public class GenshinAvatar {
}
}
// Add any skill strings from this proud skill
// Add any skill strings from this proud skill
this
.
addToAbility
List
(
proudSkillData
.
getOpenConfig
(),
true
);
this
.
addTo
Extra
Ability
Embryos
(
proudSkillData
.
getOpenConfig
(),
true
);
}
}
// Constellations
// Constellations
...
@@ -550,7 +577,7 @@ public class GenshinAvatar {
...
@@ -550,7 +577,7 @@ public class GenshinAvatar {
}
}
// Add any skill strings from this constellation
// Add any skill strings from this constellation
this
.
addToAbility
List
(
avatarTalentData
.
getOpenConfig
(),
false
);
this
.
addTo
Extra
Ability
Embryos
(
avatarTalentData
.
getOpenConfig
(),
false
);
}
}
}
}
...
@@ -573,11 +600,17 @@ public class GenshinAvatar {
...
@@ -573,11 +600,17 @@ public class GenshinAvatar {
// Packet
// Packet
if
(
getPlayer
()
!=
null
&&
getPlayer
().
hasSentAvatarDataNotify
())
{
if
(
getPlayer
()
!=
null
&&
getPlayer
().
hasSentAvatarDataNotify
())
{
// Update stats for client
getPlayer
().
sendPacket
(
new
PacketAvatarFightPropNotify
(
this
));
getPlayer
().
sendPacket
(
new
PacketAvatarFightPropNotify
(
this
));
// Update client abilities
EntityAvatar
entity
=
this
.
getAsEntity
();
if
(
entity
!=
null
&&
(!
this
.
getExtraAbilityEmbryos
().
equals
(
prevExtraAbilityEmbryos
)
||
forceSendAbilityChange
))
{
getPlayer
().
sendPacket
(
new
PacketAbilityChangeNotify
(
entity
));
}
}
}
}
}
public
void
addToAbility
List
(
String
openConfig
,
boolean
forceAdd
)
{
public
void
addTo
Extra
Ability
Embryos
(
String
openConfig
,
boolean
forceAdd
)
{
if
(
openConfig
==
null
||
openConfig
.
length
()
==
0
)
{
if
(
openConfig
==
null
||
openConfig
.
length
()
==
0
)
{
return
;
return
;
}
}
...
@@ -586,14 +619,14 @@ public class GenshinAvatar {
...
@@ -586,14 +619,14 @@ public class GenshinAvatar {
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
this
.
get
Bonus
Ability
List
().
add
(
openConfig
);
this
.
get
Extra
Ability
Embryos
().
add
(
openConfig
);
}
}
return
;
return
;
}
}
if
(
entry
.
getAddAbilities
()
!=
null
)
{
if
(
entry
.
getAddAbilities
()
!=
null
)
{
for
(
String
ability
:
entry
.
getAddAbilities
())
{
for
(
String
ability
:
entry
.
getAddAbilities
())
{
this
.
get
Bonus
Ability
List
().
add
(
ability
);
this
.
get
Extra
Ability
Embryos
().
add
(
ability
);
}
}
}
}
}
}
...
@@ -668,6 +701,20 @@ public class GenshinAvatar {
...
@@ -668,6 +701,20 @@ public class GenshinAvatar {
}
}
public
AvatarInfo
toProto
()
{
public
AvatarInfo
toProto
()
{
AvatarFetterInfo
.
Builder
avatarFetter
=
AvatarFetterInfo
.
newBuilder
()
.
setExpLevel
(
10
)
.
setExpNumber
(
6325
);
// Highest Level
if
(
this
.
getFetterList
()
!=
null
)
{
for
(
int
i
=
0
;
i
<
this
.
getFetterList
().
size
();
i
++)
{
avatarFetter
.
addFetterList
(
FetterData
.
newBuilder
()
.
setFetterId
(
this
.
getFetterList
().
get
(
i
))
.
setFetterState
(
FetterState
.
FINISH
.
getValue
())
);
}
}
AvatarInfo
.
Builder
avatarInfo
=
AvatarInfo
.
newBuilder
()
AvatarInfo
.
Builder
avatarInfo
=
AvatarInfo
.
newBuilder
()
.
setAvatarId
(
this
.
getAvatarId
())
.
setAvatarId
(
this
.
getAvatarId
())
.
setGuid
(
this
.
getGuid
())
.
setGuid
(
this
.
getGuid
())
...
@@ -681,7 +728,7 @@ public class GenshinAvatar {
...
@@ -681,7 +728,7 @@ public class GenshinAvatar {
.
putAllProudSkillExtraLevel
(
getProudSkillBonusMap
())
.
putAllProudSkillExtraLevel
(
getProudSkillBonusMap
())
.
setAvatarType
(
1
)
.
setAvatarType
(
1
)
.
setBornTime
(
this
.
getBornTime
())
.
setBornTime
(
this
.
getBornTime
())
.
setFetterInfo
(
A
vatarFetter
Info
.
newBuilder
().
setExpLevel
(
1
)
)
.
setFetterInfo
(
a
vatarFetter
)
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setCostumeId
(
this
.
getCostume
());
.
setCostumeId
(
this
.
getCostume
());
...
...
src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
View file @
e6402c31
...
@@ -223,8 +223,8 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -223,8 +223,8 @@ public class EntityAvatar extends GenshinEntity {
}
}
}
}
// Add equip abilities
// Add equip abilities
if
(
this
.
getAvatar
().
get
Bonus
Ability
List
().
size
()
>
0
)
{
if
(
this
.
getAvatar
().
get
Extra
Ability
Embryos
().
size
()
>
0
)
{
for
(
String
skill
:
this
.
getAvatar
().
get
Bonus
Ability
List
())
{
for
(
String
skill
:
this
.
getAvatar
().
get
Extra
Ability
Embryos
())
{
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
.
setAbilityId
(++
embryoId
)
.
setAbilityId
(++
embryoId
)
.
setAbilityNameHash
(
Utils
.
abilityHash
(
skill
))
.
setAbilityNameHash
(
Utils
.
abilityHash
(
skill
))
...
...
src/main/java/emu/grasscutter/game/friends/FriendsList.java
View file @
e6402c31
...
@@ -220,7 +220,7 @@ public class FriendsList {
...
@@ -220,7 +220,7 @@ public class FriendsList {
friendship
.
setOwner
(
getPlayer
());
friendship
.
setOwner
(
getPlayer
());
// Check if friend is online
// Check if friend is online
GenshinPlayer
friend
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
friendship
.
getFriendProfile
().
get
I
d
());
GenshinPlayer
friend
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
friendship
.
getFriendProfile
().
get
Ui
d
());
if
(
friend
!=
null
)
{
if
(
friend
!=
null
)
{
// Set friend to online mode
// Set friend to online mode
friendship
.
setFriendProfile
(
friend
);
friendship
.
setFriendProfile
(
friend
);
...
...
src/main/java/emu/grasscutter/game/friends/Friendship.java
View file @
e6402c31
...
@@ -88,7 +88,7 @@ public class Friendship {
...
@@ -88,7 +88,7 @@ public class Friendship {
public
FriendBrief
toProto
()
{
public
FriendBrief
toProto
()
{
FriendBrief
proto
=
FriendBrief
.
newBuilder
()
FriendBrief
proto
=
FriendBrief
.
newBuilder
()
.
setUid
(
getFriendProfile
().
get
I
d
())
.
setUid
(
getFriendProfile
().
get
Ui
d
())
.
setNickname
(
getFriendProfile
().
getName
())
.
setNickname
(
getFriendProfile
().
getName
())
.
setLevel
(
getFriendProfile
().
getPlayerLevel
())
.
setLevel
(
getFriendProfile
().
getPlayerLevel
())
.
setAvatar
(
HeadImage
.
newBuilder
().
setAvatarId
(
getFriendProfile
().
getAvatarId
()))
.
setAvatar
(
HeadImage
.
newBuilder
().
setAvatarId
(
getFriendProfile
().
getAvatarId
()))
...
...
src/main/java/emu/grasscutter/game/friends/PlayerProfile.java
View file @
e6402c31
...
@@ -7,7 +7,7 @@ import emu.grasscutter.utils.Utils;
...
@@ -7,7 +7,7 @@ import emu.grasscutter.utils.Utils;
public
class
PlayerProfile
{
public
class
PlayerProfile
{
@Transient
private
GenshinPlayer
player
;
@Transient
private
GenshinPlayer
player
;
private
int
id
;
@AlsoLoad
(
"id"
)
private
int
u
id
;
private
int
nameCard
;
private
int
nameCard
;
private
int
avatarId
;
private
int
avatarId
;
private
String
name
;
private
String
name
;
...
@@ -22,12 +22,12 @@ public class PlayerProfile {
...
@@ -22,12 +22,12 @@ public class PlayerProfile {
public
PlayerProfile
()
{
}
public
PlayerProfile
()
{
}
public
PlayerProfile
(
GenshinPlayer
player
)
{
public
PlayerProfile
(
GenshinPlayer
player
)
{
this
.
id
=
player
.
getUid
();
this
.
u
id
=
player
.
getUid
();
this
.
syncWithCharacter
(
player
);
this
.
syncWithCharacter
(
player
);
}
}
public
int
get
I
d
()
{
public
int
get
Ui
d
()
{
return
id
;
return
u
id
;
}
}
public
GenshinPlayer
getPlayer
()
{
public
GenshinPlayer
getPlayer
()
{
...
@@ -87,6 +87,7 @@ public class PlayerProfile {
...
@@ -87,6 +87,7 @@ public class PlayerProfile {
return
;
return
;
}
}
this
.
uid
=
player
.
getUid
();
this
.
name
=
player
.
getNickname
();
this
.
name
=
player
.
getNickname
();
this
.
avatarId
=
player
.
getHeadImage
();
this
.
avatarId
=
player
.
getHeadImage
();
this
.
signature
=
player
.
getSignature
();
this
.
signature
=
player
.
getSignature
();
...
...
src/main/java/emu/grasscutter/game/gacha/GachaBanner.java
View file @
e6402c31
...
@@ -92,7 +92,7 @@ public class GachaBanner {
...
@@ -92,7 +92,7 @@ public class GachaBanner {
}
}
public
GachaInfo
toProto
()
{
public
GachaInfo
toProto
()
{
String
record
=
"http://"
+
(
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
Dispatch
Server
Ip
:
Grasscutter
.
getConfig
().
Dispatch
Server
PublicIp
)
+
"/gacha"
;
String
record
=
"http://"
+
(
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
Ip
:
Grasscutter
.
getConfig
().
get
Dispatch
Options
().
PublicIp
)
+
"/gacha"
;
GachaInfo
.
Builder
info
=
GachaInfo
.
newBuilder
()
GachaInfo
.
Builder
info
=
GachaInfo
.
newBuilder
()
.
setGachaType
(
this
.
getGachaType
())
.
setGachaType
(
this
.
getGachaType
())
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
e6402c31
package
emu.grasscutter.game.gacha
;
package
emu.grasscutter.game.gacha
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileReader
;
import
java.nio.file.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
...
@@ -8,6 +10,7 @@ import java.util.concurrent.ThreadLocalRandom;
...
@@ -8,6 +10,7 @@ import java.util.concurrent.ThreadLocalRandom;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
com.sun.nio.file.SensitivityWatchEventModifier
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.ItemData
;
...
@@ -21,16 +24,19 @@ import emu.grasscutter.net.proto.GachaTransferItemOuterClass.GachaTransferItem;
...
@@ -21,16 +24,19 @@ import emu.grasscutter.net.proto.GachaTransferItemOuterClass.GachaTransferItem;
import
emu.grasscutter.net.proto.GetGachaInfoRspOuterClass.GetGachaInfoRsp
;
import
emu.grasscutter.net.proto.GetGachaInfoRspOuterClass.GetGachaInfoRsp
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServerTickEvent
;
import
emu.grasscutter.server.packet.send.PacketDoGachaRsp
;
import
emu.grasscutter.server.packet.send.PacketDoGachaRsp
;
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
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.ints.IntList
;
import
it.unimi.dsi.fastutil.ints.IntList
;
import
org.greenrobot.eventbus.Subscribe
;
public
class
GachaManager
{
public
class
GachaManager
{
private
final
GameServer
server
;
private
final
GameServer
server
;
private
final
Int2ObjectMap
<
GachaBanner
>
gachaBanners
;
private
final
Int2ObjectMap
<
GachaBanner
>
gachaBanners
;
private
GetGachaInfoRsp
cachedProto
;
private
GetGachaInfoRsp
cachedProto
;
WatchService
watchService
;
private
int
[]
yellowAvatars
=
new
int
[]
{
1003
,
1016
,
1042
,
1035
,
1041
};
private
int
[]
yellowAvatars
=
new
int
[]
{
1003
,
1016
,
1042
,
1035
,
1041
};
private
int
[]
yellowWeapons
=
new
int
[]
{
11501
,
11502
,
12501
,
12502
,
13502
,
13505
,
14501
,
14502
,
15501
,
15502
};
private
int
[]
yellowWeapons
=
new
int
[]
{
11501
,
11502
,
12501
,
12502
,
13502
,
13505
,
14501
,
14502
,
15501
,
15502
};
...
@@ -45,6 +51,7 @@ public class GachaManager {
...
@@ -45,6 +51,7 @@ public class GachaManager {
this
.
server
=
server
;
this
.
server
=
server
;
this
.
gachaBanners
=
new
Int2ObjectOpenHashMap
<>();
this
.
gachaBanners
=
new
Int2ObjectOpenHashMap
<>();
this
.
load
();
this
.
load
();
this
.
startWatcher
(
server
);
}
}
public
GameServer
getServer
()
{
public
GameServer
getServer
()
{
...
@@ -65,10 +72,17 @@ public class GachaManager {
...
@@ -65,10 +72,17 @@ public class GachaManager {
public
synchronized
void
load
()
{
public
synchronized
void
load
()
{
try
(
FileReader
fileReader
=
new
FileReader
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"Banners.json"
))
{
try
(
FileReader
fileReader
=
new
FileReader
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"Banners.json"
))
{
getGachaBanners
().
clear
();
List
<
GachaBanner
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
GachaBanner
.
class
).
getType
());
List
<
GachaBanner
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
GachaBanner
.
class
).
getType
());
if
(
banners
.
size
()
>
0
)
{
for
(
GachaBanner
banner
:
banners
)
{
for
(
GachaBanner
banner
:
banners
)
{
getGachaBanners
().
put
(
banner
.
getGachaType
(),
banner
);
getGachaBanners
().
put
(
banner
.
getGachaType
(),
banner
);
}
}
Grasscutter
.
getLogger
().
info
(
"Banners successfully loaded."
);
this
.
cachedProto
=
createProto
();
}
else
{
Grasscutter
.
getLogger
().
error
(
"Unable to load banners. Banners size is 0."
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -204,7 +218,6 @@ public class GachaManager {
...
@@ -204,7 +218,6 @@ public class GachaManager {
addStarglitter
=
2
;
addStarglitter
=
2
;
// Add 1 const
// Add 1 const
gachaItem
.
addTransferItems
(
GachaTransferItem
.
newBuilder
().
setItem
(
ItemParam
.
newBuilder
().
setItemId
(
constItemId
).
setCount
(
1
)).
setIsTransferItemNew
(
constItem
==
null
));
gachaItem
.
addTransferItems
(
GachaTransferItem
.
newBuilder
().
setItem
(
ItemParam
.
newBuilder
().
setItemId
(
constItemId
).
setCount
(
1
)).
setIsTransferItemNew
(
constItem
==
null
));
gachaItem
.
addTokenItemList
(
ItemParam
.
newBuilder
().
setItemId
(
constItemId
).
setCount
(
1
));
player
.
getInventory
().
addItem
(
constItemId
,
1
);
player
.
getInventory
().
addItem
(
constItemId
,
1
);
}
else
{
}
else
{
// Is max const
// Is max const
...
@@ -267,6 +280,48 @@ public class GachaManager {
...
@@ -267,6 +280,48 @@ public class GachaManager {
player
.
sendPacket
(
new
PacketDoGachaRsp
(
banner
,
list
));
player
.
sendPacket
(
new
PacketDoGachaRsp
(
banner
,
list
));
}
}
private
synchronized
void
startWatcher
(
GameServer
server
)
{
if
(
this
.
watchService
==
null
)
{
try
{
this
.
watchService
=
FileSystems
.
getDefault
().
newWatchService
();
Path
path
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
).
toPath
();
path
.
register
(
watchService
,
new
WatchEvent
.
Kind
[]{
StandardWatchEventKinds
.
ENTRY_MODIFY
},
SensitivityWatchEventModifier
.
HIGH
);
server
.
OnGameServerTick
.
register
(
this
);
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Unable to load the Gacha Manager Watch Service. If ServerOptions.watchGacha is true it will not auto-reload"
);
e
.
printStackTrace
();
}
}
else
{
Grasscutter
.
getLogger
().
error
(
"Cannot reinitialise watcher "
);
}
}
@Subscribe
public
synchronized
void
watchBannerJson
(
GameServerTickEvent
tickEvent
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
WatchGacha
)
{
try
{
WatchKey
watchKey
=
watchService
.
take
();
for
(
WatchEvent
<?>
event
:
watchKey
.
pollEvents
())
{
final
Path
changed
=
(
Path
)
event
.
context
();
if
(
changed
.
endsWith
(
"Banners.json"
))
{
Grasscutter
.
getLogger
().
info
(
"Change detected with banners.json. Reloading gacha config"
);
this
.
load
();
}
}
boolean
valid
=
watchKey
.
reset
();
if
(!
valid
)
{
Grasscutter
.
getLogger
().
error
(
"Unable to reset Gacha Manager Watch Key. Auto-reload of banners.json will no longer work."
);
return
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
private
synchronized
GetGachaInfoRsp
createProto
()
{
private
synchronized
GetGachaInfoRsp
createProto
()
{
GetGachaInfoRsp
.
Builder
proto
=
GetGachaInfoRsp
.
newBuilder
().
setGachaRandom
(
12345
);
GetGachaInfoRsp
.
Builder
proto
=
GetGachaInfoRsp
.
newBuilder
().
setGachaRandom
(
12345
);
...
...
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
e6402c31
...
@@ -37,10 +37,10 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -37,10 +37,10 @@ public class Inventory implements Iterable<GenshinItem> {
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitFurniture
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
get
Game
ServerOptions
().
InventoryLimitFurniture
));
}
}
public
GenshinPlayer
getPlayer
()
{
public
GenshinPlayer
getPlayer
()
{
...
...
src/main/java/emu/grasscutter/game/managers/ChatManager.java
View file @
e6402c31
package
emu.grasscutter.game.managers
;
package
emu.grasscutter.game.managers
;
import
emu.grasscutter.command
s
.CommandMap
;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
...
...
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
e6402c31
...
@@ -471,7 +471,7 @@ public class InventoryManager {
...
@@ -471,7 +471,7 @@ public class InventoryManager {
}
}
// Consume weapon
// Consume weapon
player
.
getInventory
().
removeItem
(
feed
);
player
.
getInventory
().
removeItem
(
feed
,
1
);
// Get
// Get
weapon
.
setRefinement
(
targetRefineLevel
);
weapon
.
setRefinement
(
targetRefineLevel
);
...
@@ -589,7 +589,6 @@ public class InventoryManager {
...
@@ -589,7 +589,6 @@ public class InventoryManager {
// Update proud skills
// Update proud skills
AvatarSkillDepotData
skillDepot
=
GenshinData
.
getAvatarSkillDepotDataMap
().
get
(
avatar
.
getSkillDepotId
());
AvatarSkillDepotData
skillDepot
=
GenshinData
.
getAvatarSkillDepotDataMap
().
get
(
avatar
.
getSkillDepotId
());
boolean
hasAddedProudSkill
=
false
;
if
(
skillDepot
!=
null
&&
skillDepot
.
getInherentProudSkillOpens
()
!=
null
)
{
if
(
skillDepot
!=
null
&&
skillDepot
.
getInherentProudSkillOpens
()
!=
null
)
{
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
...
@@ -599,7 +598,6 @@ public class InventoryManager {
...
@@ -599,7 +598,6 @@ public class InventoryManager {
if
(
openData
.
getNeedAvatarPromoteLevel
()
==
avatar
.
getPromoteLevel
())
{
if
(
openData
.
getNeedAvatarPromoteLevel
()
==
avatar
.
getPromoteLevel
())
{
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
if
(
GenshinData
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
if
(
GenshinData
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
hasAddedProudSkill
=
true
;
avatar
.
getProudSkillList
().
add
(
proudSkillId
);
avatar
.
getProudSkillList
().
add
(
proudSkillId
);
player
.
sendPacket
(
new
PacketProudSkillChangeNotify
(
avatar
));
player
.
sendPacket
(
new
PacketProudSkillChangeNotify
(
avatar
));
}
}
...
@@ -607,20 +605,13 @@ public class InventoryManager {
...
@@ -607,20 +605,13 @@ public class InventoryManager {
}
}
}
}
// Racalc stats and save avatar
avatar
.
recalcStats
();
avatar
.
save
();
// Resend ability embryos if proud skill has been added
if
(
hasAddedProudSkill
&&
avatar
.
getAsEntity
()
!=
null
)
{
player
.
sendPacket
(
new
PacketAbilityChangeNotify
(
avatar
.
getAsEntity
()));
}
// TODO Send entity prop update packet to world
// Packets
// Packets
player
.
sendPacket
(
new
PacketAvatarPropNotify
(
avatar
));
player
.
sendPacket
(
new
PacketAvatarPropNotify
(
avatar
));
player
.
sendPacket
(
new
PacketAvatarPromoteRsp
(
avatar
));
player
.
sendPacket
(
new
PacketAvatarPromoteRsp
(
avatar
));
// TODO Send entity prop update packet to world
avatar
.
recalcStats
(
true
);
avatar
.
save
();
}
}
public
void
upgradeAvatar
(
GenshinPlayer
player
,
long
guid
,
int
itemId
,
int
count
)
{
public
void
upgradeAvatar
(
GenshinPlayer
player
,
long
guid
,
int
itemId
,
int
count
)
{
...
@@ -804,6 +795,12 @@ public class InventoryManager {
...
@@ -804,6 +795,12 @@ public class InventoryManager {
// Get talent
// Get talent
int
currentTalentLevel
=
avatar
.
getCoreProudSkillLevel
();
int
currentTalentLevel
=
avatar
.
getCoreProudSkillLevel
();
int
nextTalentId
=
((
avatar
.
getAvatarId
()
%
10000000
)
*
10
)
+
currentTalentLevel
+
1
;
int
nextTalentId
=
((
avatar
.
getAvatarId
()
%
10000000
)
*
10
)
+
currentTalentLevel
+
1
;
if
(
avatar
.
getAvatarId
()
==
10000006
)
{
// Lisa is special in that her talentId starts with 4 instead of 6.
nextTalentId
=
40
+
currentTalentLevel
+
1
;
}
AvatarTalentData
talentData
=
GenshinData
.
getAvatarTalentDataMap
().
get
(
nextTalentId
);
AvatarTalentData
talentData
=
GenshinData
.
getAvatarTalentDataMap
().
get
(
nextTalentId
);
if
(
talentData
==
null
)
{
if
(
talentData
==
null
)
{
...
@@ -821,25 +818,20 @@ public class InventoryManager {
...
@@ -821,25 +818,20 @@ public class InventoryManager {
// Apply + recalc
// Apply + recalc
avatar
.
getTalentIdList
().
add
(
talentData
.
getId
());
avatar
.
getTalentIdList
().
add
(
talentData
.
getId
());
avatar
.
setCoreProudSkillLevel
(
currentTalentLevel
+
1
);
avatar
.
setCoreProudSkillLevel
(
currentTalentLevel
+
1
);
avatar
.
recalcStats
();
// Packet
// Packet
player
.
sendPacket
(
new
PacketAvatarUnlockTalentNotify
(
avatar
,
nextTalentId
));
player
.
sendPacket
(
new
PacketAvatarUnlockTalentNotify
(
avatar
,
nextTalentId
));
player
.
sendPacket
(
new
PacketUnlockAvatarTalentRsp
(
avatar
,
nextTalentId
));
player
.
sendPacket
(
new
PacketUnlockAvatarTalentRsp
(
avatar
,
nextTalentId
));
// Proud skill bonus map
// Proud skill bonus map
(Extra skills)
OpenConfigEntry
entry
=
GenshinData
.
getOpenConfigEntries
().
get
(
talentData
.
getOpenConfig
());
OpenConfigEntry
entry
=
GenshinData
.
getOpenConfigEntries
().
get
(
talentData
.
getOpenConfig
());
if
(
entry
!=
null
&&
entry
.
getExtraTalentIndex
()
>
0
)
{
if
(
entry
!=
null
&&
entry
.
getExtraTalentIndex
()
>
0
)
{
avatar
.
recalcProudSkillBonusMap
();
avatar
.
recalcProudSkillBonusMap
();
player
.
sendPacket
(
new
PacketProudSkillExtraLevelNotify
(
avatar
,
entry
.
getExtraTalentIndex
()));
player
.
sendPacket
(
new
PacketProudSkillExtraLevelNotify
(
avatar
,
entry
.
getExtraTalentIndex
()));
}
}
// Resend ability embryos
// Recalc + save avatar
if
(
avatar
.
getAsEntity
()
!=
null
)
{
avatar
.
recalcStats
(
true
);
player
.
sendPacket
(
new
PacketAbilityChangeNotify
(
avatar
.
getAsEntity
()));
}
// Save avatar
avatar
.
save
();
avatar
.
save
();
}
}
...
...
src/main/java/emu/grasscutter/game/props/FetterState.java
0 → 100644
View file @
e6402c31
package
emu.grasscutter.game.props
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Stream
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
FetterState
{
NONE
(
0
),
NOT_OPEN
(
1
),
OPEN
(
1
),
FINISH
(
3
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
FetterState
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
FetterState
>
stringMap
=
new
HashMap
<>();
static
{
Stream
.
of
(
values
()).
forEach
(
e
->
{
map
.
put
(
e
.
getValue
(),
e
);
stringMap
.
put
(
e
.
name
(),
e
);
});
}
private
FetterState
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
public
static
FetterState
getTypeByValue
(
int
value
)
{
return
map
.
getOrDefault
(
value
,
NONE
);
}
public
static
FetterState
getTypeByName
(
String
name
)
{
return
stringMap
.
getOrDefault
(
name
,
NONE
);
}
}
src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java
View file @
e6402c31
This diff is collapsed.
Click to expand it.
src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenReqJson.java
View file @
e6402c31
...
@@ -7,7 +7,7 @@ public class ComboTokenReqJson {
...
@@ -7,7 +7,7 @@ public class ComboTokenReqJson {
public
String
device
;
public
String
device
;
public
String
sign
;
public
String
sign
;
public
class
LoginTokenData
{
public
static
class
LoginTokenData
{
public
String
uid
;
public
String
uid
;
public
String
token
;
public
String
token
;
public
boolean
guest
;
public
boolean
guest
;
...
...
src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenResJson.java
View file @
e6402c31
...
@@ -5,7 +5,7 @@ public class ComboTokenResJson {
...
@@ -5,7 +5,7 @@ public class ComboTokenResJson {
public
int
retcode
;
public
int
retcode
;
public
LoginData
data
=
new
LoginData
();
public
LoginData
data
=
new
LoginData
();
public
class
LoginData
{
public
static
class
LoginData
{
public
int
account_type
=
1
;
public
int
account_type
=
1
;
public
boolean
heartbeat
;
public
boolean
heartbeat
;
public
String
combo_id
;
public
String
combo_id
;
...
...
src/main/java/emu/grasscutter/server/dispatch/json/LoginResultJson.java
View file @
e6402c31
...
@@ -5,7 +5,7 @@ public class LoginResultJson {
...
@@ -5,7 +5,7 @@ public class LoginResultJson {
public
int
retcode
;
public
int
retcode
;
public
VerifyData
data
=
new
VerifyData
();
public
VerifyData
data
=
new
VerifyData
();
public
class
VerifyData
{
public
static
class
VerifyData
{
public
VerifyAccountData
account
=
new
VerifyAccountData
();
public
VerifyAccountData
account
=
new
VerifyAccountData
();
public
boolean
device_grant_required
=
false
;
public
boolean
device_grant_required
=
false
;
public
String
realname_operation
=
"NONE"
;
public
String
realname_operation
=
"NONE"
;
...
@@ -13,7 +13,7 @@ public class LoginResultJson {
...
@@ -13,7 +13,7 @@ public class LoginResultJson {
public
boolean
safe_mobile_required
=
false
;
public
boolean
safe_mobile_required
=
false
;
}
}
public
class
VerifyAccountData
{
public
static
class
VerifyAccountData
{
public
String
uid
;
public
String
uid
;
public
String
name
=
""
;
public
String
name
=
""
;
public
String
email
;
public
String
email
;
...
...
src/main/java/emu/grasscutter/server/game/GameServer.java
View file @
e6402c31
...
@@ -6,7 +6,7 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -6,7 +6,7 @@ import java.util.concurrent.ConcurrentHashMap;
import
emu.grasscutter.GenshinConstants
;
import
emu.grasscutter.GenshinConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.command
s
.CommandMap
;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.GenshinPlayer
;
...
@@ -19,6 +19,7 @@ import emu.grasscutter.game.shop.ShopManager;
...
@@ -19,6 +19,7 @@ import emu.grasscutter.game.shop.ShopManager;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.netty.MihoyoKcpServer
;
import
emu.grasscutter.netty.MihoyoKcpServer
;
import
org.greenrobot.eventbus.EventBus
;
public
final
class
GameServer
extends
MihoyoKcpServer
{
public
final
class
GameServer
extends
MihoyoKcpServer
{
private
final
InetSocketAddress
address
;
private
final
InetSocketAddress
address
;
...
@@ -34,9 +35,17 @@ public final class GameServer extends MihoyoKcpServer {
...
@@ -34,9 +35,17 @@ public final class GameServer extends MihoyoKcpServer {
private
final
DungeonManager
dungeonManager
;
private
final
DungeonManager
dungeonManager
;
private
final
CommandMap
commandMap
;
private
final
CommandMap
commandMap
;
public
EventBus
OnGameServerStartFinish
;
public
EventBus
OnGameServerTick
;
public
EventBus
OnGameServerStop
;
public
GameServer
(
InetSocketAddress
address
)
{
public
GameServer
(
InetSocketAddress
address
)
{
super
(
address
);
super
(
address
);
OnGameServerStartFinish
=
EventBus
.
builder
().
throwSubscriberException
(
true
).
logNoSubscriberMessages
(
false
).
build
();
OnGameServerTick
=
EventBus
.
builder
().
throwSubscriberException
(
true
).
logNoSubscriberMessages
(
false
).
build
();
OnGameServerStop
=
EventBus
.
builder
().
throwSubscriberException
(
true
).
logNoSubscriberMessages
(
false
).
build
();
this
.
setServerInitializer
(
new
GameServerInitializer
(
this
));
this
.
setServerInitializer
(
new
GameServerInitializer
(
this
));
this
.
address
=
address
;
this
.
address
=
address
;
this
.
packetHandler
=
new
GameServerPacketHandler
(
PacketHandler
.
class
);
this
.
packetHandler
=
new
GameServerPacketHandler
(
PacketHandler
.
class
);
...
@@ -145,7 +154,7 @@ public final class GameServer extends MihoyoKcpServer {
...
@@ -145,7 +154,7 @@ public final class GameServer extends MihoyoKcpServer {
public
Account
getAccountByName
(
String
username
)
{
public
Account
getAccountByName
(
String
username
)
{
Optional
<
GenshinPlayer
>
playerOpt
=
getPlayers
().
values
().
stream
().
filter
(
player
->
player
.
getAccount
().
getUsername
().
equals
(
username
)).
findFirst
();
Optional
<
GenshinPlayer
>
playerOpt
=
getPlayers
().
values
().
stream
().
filter
(
player
->
player
.
getAccount
().
getUsername
().
equals
(
username
)).
findFirst
();
if
(
playerOpt
.
get
()
!=
null
)
{
if
(
playerOpt
.
isPresent
()
)
{
return
playerOpt
.
get
().
getAccount
();
return
playerOpt
.
get
().
getAccount
();
}
}
return
DatabaseHelper
.
getAccountByName
(
username
);
return
DatabaseHelper
.
getAccountByName
(
username
);
...
@@ -155,14 +164,20 @@ public final class GameServer extends MihoyoKcpServer {
...
@@ -155,14 +164,20 @@ public final class GameServer extends MihoyoKcpServer {
for
(
GenshinPlayer
player
:
this
.
getPlayers
().
values
())
{
for
(
GenshinPlayer
player
:
this
.
getPlayers
().
values
())
{
player
.
onTick
();
player
.
onTick
();
}
}
OnGameServerTick
.
post
(
new
GameServerTickEvent
());
}
}
@Override
@Override
public
void
onStartFinish
()
{
public
void
onStartFinish
()
{
Grasscutter
.
getLogger
().
info
(
"Game Server started on port "
+
address
.
getPort
());
Grasscutter
.
getLogger
().
info
(
"Game Server started on port "
+
address
.
getPort
());
OnGameServerStartFinish
.
post
(
new
GameServerStartFinishEvent
());
}
}
public
void
onServerShutdown
()
{
public
void
onServerShutdown
()
{
OnGameServerStop
.
post
(
new
GameServerStopEvent
());
// Kick and save all players
// Kick and save all players
List
<
GenshinPlayer
>
list
=
new
ArrayList
<>(
this
.
getPlayers
().
size
());
List
<
GenshinPlayer
>
list
=
new
ArrayList
<>(
this
.
getPlayers
().
size
());
list
.
addAll
(
this
.
getPlayers
().
values
());
list
.
addAll
(
this
.
getPlayers
().
values
());
...
...
src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java
View file @
e6402c31
...
@@ -87,7 +87,7 @@ public class GameServerPacketHandler {
...
@@ -87,7 +87,7 @@ public class GameServerPacketHandler {
}
}
// Log unhandled packets
// Log unhandled packets
if
(
Grasscutter
.
getConfig
().
LOG_PACKETS
)
{
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode));
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode));
}
}
}
}
...
...
src/main/java/emu/grasscutter/server/game/GameServerStartFinishEvent.java
0 → 100644
View file @
e6402c31
package
emu.grasscutter.server.game
;
public
class
GameServerStartFinishEvent
{
// Placeholder class for now, probably will get used later
}
src/main/java/emu/grasscutter/server/game/GameServerStopEvent.java
0 → 100644
View file @
e6402c31
This diff is collapsed.
Click to expand it.
src/main/java/emu/grasscutter/server/game/GameServerTickEvent.java
0 → 100644
View file @
e6402c31
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
6
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