Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grasscutter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ziqian zhang
Grasscutter
Commits
3a2ebd1e
Commit
3a2ebd1e
authored
3 years ago
by
GanyusLeftHorn
Committed by
Melledy
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Set world level automatically on level up.
parent
f5145efb
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/emu/grasscutter/game/player/Player.java
+32
-6
32 additions, 6 deletions
src/main/java/emu/grasscutter/game/player/Player.java
with
32 additions
and
6 deletions
src/main/java/emu/grasscutter/game/player/Player.java
+
32
−
6
View file @
3a2ebd1e
...
@@ -429,6 +429,14 @@ public class Player {
...
@@ -429,6 +429,14 @@ public class Player {
return
this
.
getProperty
(
PlayerProperty
.
PROP_PLAYER_LEVEL
);
return
this
.
getProperty
(
PlayerProperty
.
PROP_PLAYER_LEVEL
);
}
}
public
void
setLevel
(
int
level
)
{
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_LEVEL
,
level
);
this
.
sendPacket
(
new
PacketPlayerPropNotify
(
this
,
PlayerProperty
.
PROP_PLAYER_LEVEL
));
this
.
updateWorldLevel
();
this
.
updateProfile
();
}
public
int
getExp
()
{
public
int
getExp
()
{
return
this
.
getProperty
(
PlayerProperty
.
PROP_PLAYER_EXP
);
return
this
.
getProperty
(
PlayerProperty
.
PROP_PLAYER_EXP
);
}
}
...
@@ -440,6 +448,8 @@ public class Player {
...
@@ -440,6 +448,8 @@ public class Player {
public
void
setWorldLevel
(
int
level
)
{
public
void
setWorldLevel
(
int
level
)
{
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_WORLD_LEVEL
,
level
);
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_WORLD_LEVEL
,
level
);
this
.
sendPacket
(
new
PacketPlayerPropNotify
(
this
,
PlayerProperty
.
PROP_PLAYER_WORLD_LEVEL
));
this
.
sendPacket
(
new
PacketPlayerPropNotify
(
this
,
PlayerProperty
.
PROP_PLAYER_WORLD_LEVEL
));
this
.
updateProfile
();
}
}
public
int
getPrimogems
()
{
public
int
getPrimogems
()
{
...
@@ -508,12 +518,7 @@ public class Player {
...
@@ -508,12 +518,7 @@ public class Player {
}
}
if
(
hasLeveledUp
)
{
if
(
hasLeveledUp
)
{
// Set level property
this
.
setLevel
(
level
);
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_LEVEL
,
level
);
// Update social status
this
.
updateProfile
();
// Update player with packet
this
.
sendPacket
(
new
PacketPlayerPropNotify
(
this
,
PlayerProperty
.
PROP_PLAYER_LEVEL
));
}
}
// Set exp
// Set exp
...
@@ -523,6 +528,27 @@ public class Player {
...
@@ -523,6 +528,27 @@ public class Player {
this
.
sendPacket
(
new
PacketPlayerPropNotify
(
this
,
PlayerProperty
.
PROP_PLAYER_EXP
));
this
.
sendPacket
(
new
PacketPlayerPropNotify
(
this
,
PlayerProperty
.
PROP_PLAYER_EXP
));
}
}
private
void
updateWorldLevel
()
{
int
currentWorldLevel
=
this
.
getWorldLevel
();
int
currentLevel
=
this
.
getLevel
();
int
newWorldLevel
=
(
currentLevel
>=
55
)
?
8
:
(
currentLevel
>=
50
)
?
7
:
(
currentLevel
>=
45
)
?
6
:
(
currentLevel
>=
40
)
?
5
:
(
currentLevel
>=
35
)
?
4
:
(
currentLevel
>=
30
)
?
3
:
(
currentLevel
>=
25
)
?
2
:
(
currentLevel
>=
20
)
?
1
:
0
;
if
(
newWorldLevel
!=
currentWorldLevel
)
{
this
.
getWorld
().
setWorldLevel
(
newWorldLevel
);
this
.
setWorldLevel
(
newWorldLevel
);
}
}
private
void
updateProfile
()
{
private
void
updateProfile
()
{
getProfile
().
syncWithCharacter
(
this
);
getProfile
().
syncWithCharacter
(
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment