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
2e69a4d8
Commit
2e69a4d8
authored
May 10, 2022
by
Akka
Browse files
Merge remote-tracking branch 'origin/development' into tower
parents
faa3cde5
c2a7d607
Changes
34
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java
View file @
2e69a4d8
...
...
@@ -10,7 +10,7 @@ import java.util.List;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"setworldlevel"
,
usage
=
"setworldlevel <level>"
,
aliases
=
{
"setworldlvl"
},
permission
=
"player.setworldlevel"
,
description
=
"commands.setWorldLevel.description"
)
aliases
=
{
"setworldlvl"
},
permission
=
"player.setworldlevel"
,
permissionTargeted
=
"player.setworldlevel.others"
,
description
=
"commands.setWorldLevel.description"
)
public
final
class
SetWorldLevelCommand
implements
CommandHandler
{
@Override
...
...
src/main/java/emu/grasscutter/command/commands/SpawnCommand.java
View file @
2e69a4d8
...
...
@@ -22,7 +22,7 @@ import java.util.Random;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"spawn"
,
usage
=
"spawn <entityId> [amount] [level(monster only)]"
,
permission
=
"server.spawn"
,
description
=
"commands.spawn.description"
)
@Command
(
label
=
"spawn"
,
usage
=
"spawn <entityId> [amount] [level(monster only)]"
,
permission
=
"server.spawn"
,
permissionTargeted
=
"server.spawn.others"
,
description
=
"commands.spawn.description"
)
public
final
class
SpawnCommand
implements
CommandHandler
{
@Override
...
...
@@ -46,13 +46,13 @@ public final class SpawnCommand implements CommandHandler {
try
{
amount
=
Integer
.
parseInt
(
args
.
get
(
1
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.
error
.amount"
));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.
invalid
.amount"
));
}
// Fallthrough
case
1
:
try
{
id
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.
error
.entityId"
));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.
invalid
.entityId"
));
}
break
;
default
:
...
...
@@ -64,7 +64,7 @@ public final class SpawnCommand implements CommandHandler {
GadgetData
gadgetData
=
GameData
.
getGadgetDataMap
().
get
(
id
);
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
id
);
if
(
monsterData
==
null
&&
gadgetData
==
null
&&
itemData
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.
error
.entityId"
));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.
invalid
.entityId"
));
return
;
}
Scene
scene
=
targetPlayer
.
getScene
();
...
...
src/main/java/emu/grasscutter/command/commands/TalentCommand.java
View file @
2e69a4d8
...
...
@@ -14,7 +14,7 @@ import java.util.List;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"talent"
,
usage
=
"talent <talentID> <value>"
,
permission
=
"player.settalent"
,
description
=
"commands.talent.description"
)
@Command
(
label
=
"talent"
,
usage
=
"talent <talentID> <value>"
,
permission
=
"player.settalent"
,
permissionTargeted
=
"player.settalent.others"
,
description
=
"commands.talent.description"
)
public
final
class
TalentCommand
implements
CommandHandler
{
private
void
setTalentLevel
(
Player
sender
,
Player
player
,
Avatar
avatar
,
int
talentId
,
int
talentLevel
)
{
int
oldLevel
=
avatar
.
getSkillLevelMap
().
get
(
talentId
);
...
...
@@ -24,7 +24,7 @@ public final class TalentCommand implements CommandHandler {
}
// Upgrade skill
avatar
.
getSkillLevelMap
().
put
(
talent
Level
,
talentLevel
);
avatar
.
getSkillLevelMap
().
put
(
talent
Id
,
talentLevel
);
avatar
.
save
();
// Packet
...
...
src/main/java/emu/grasscutter/command/commands/TeleportAllCommand.java
View file @
2e69a4d8
...
...
@@ -10,7 +10,7 @@ import java.util.List;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"tpall"
,
usage
=
"tpall"
,
permission
=
"player.tpall"
,
description
=
"commands.teleportAll.description"
)
@Command
(
label
=
"tpall"
,
usage
=
"tpall"
,
permission
=
"player.tpall"
,
permissionTargeted
=
"player.tpall.others"
,
description
=
"commands.teleportAll.description"
)
public
final
class
TeleportAllCommand
implements
CommandHandler
{
@Override
...
...
src/main/java/emu/grasscutter/command/commands/TeleportCommand.java
View file @
2e69a4d8
...
...
@@ -10,7 +10,7 @@ import java.util.List;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"teleport"
,
usage
=
"teleport <x> <y> <z> [scene id]"
,
aliases
=
{
"tp"
},
permission
=
"player.teleport"
,
description
=
"commands.teleport.description"
)
@Command
(
label
=
"teleport"
,
usage
=
"teleport <x> <y> <z> [scene id]"
,
aliases
=
{
"tp"
},
permission
=
"player.teleport"
,
permissionTargeted
=
"player.teleport.others"
,
description
=
"commands.teleport.description"
)
public
final
class
TeleportCommand
implements
CommandHandler
{
private
float
parseRelative
(
String
input
,
Float
current
)
{
// TODO: Maybe this will be useful elsewhere later
...
...
src/main/java/emu/grasscutter/command/commands/UnlockTowerCommand.java
View file @
2e69a4d8
...
...
@@ -10,7 +10,7 @@ import java.util.List;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"unlocktower"
,
usage
=
"unlocktower"
,
aliases
=
{
"ut"
},
description
=
"
Unlock all levels of tower
"
,
permission
=
"player.tower"
)
description
=
"
commands.unlocktower.description
"
,
permission
=
"player.tower"
)
public
class
UnlockTowerCommand
implements
CommandHandler
{
@Override
...
...
@@ -21,7 +21,7 @@ public class UnlockTowerCommand implements CommandHandler {
unlockFloor
(
sender
,
sender
.
getServer
().
getTowerScheduleManager
()
.
getScheduleFloors
());
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.
tower.unlock_done
"
));
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.
unlocktower.success
"
));
}
public
void
unlockFloor
(
Player
player
,
List
<
Integer
>
floors
){
...
...
src/main/java/emu/grasscutter/command/commands/WeatherCommand.java
View file @
2e69a4d8
...
...
@@ -11,7 +11,7 @@ import java.util.List;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"weather"
,
usage
=
"weather <weatherId> [climateId]"
,
aliases
=
{
"w"
},
permission
=
"player.weather"
,
description
=
"commands.weather.description"
)
@Command
(
label
=
"weather"
,
usage
=
"weather <weatherId> [climateId]"
,
aliases
=
{
"w"
},
permission
=
"player.weather"
,
permissionTargeted
=
"player.weather.others"
,
description
=
"commands.weather.description"
)
public
final
class
WeatherCommand
implements
CommandHandler
{
@Override
...
...
src/main/java/emu/grasscutter/game/Account.java
View file @
2e69a4d8
package
emu.grasscutter.game
;
import
dev.morphia.annotations.*
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.Utils
;
...
...
@@ -107,11 +108,41 @@ public class Account {
this
.
permissions
.
add
(
permission
);
return
true
;
}
public
static
boolean
permissionMatchesWildcard
(
String
wildcard
,
String
[]
permissionParts
)
{
String
[]
wildcardParts
=
wildcard
.
split
(
"\\."
);
if
(
permissionParts
.
length
<
wildcardParts
.
length
)
{
// A longer wildcard can never match a shorter permission
return
false
;
}
for
(
int
i
=
0
;
i
<
wildcardParts
.
length
;
i
++)
{
switch
(
wildcardParts
[
i
])
{
case
"**"
:
// Recursing match
return
true
;
case
"*"
:
// Match only one layer
if
(
i
>=
(
permissionParts
.
length
-
1
))
{
return
true
;
}
break
;
default
:
// This layer isn't a wildcard, it needs to match exactly
if
(!
wildcardParts
[
i
].
equals
(
permissionParts
[
i
]))
{
return
false
;
}
}
}
// At this point the wildcard will have matched every layer, but if it is shorter then the permission then this is not a match at this point (no **).
return
(
wildcardParts
.
length
==
permissionParts
.
length
);
}
public
boolean
hasPermission
(
String
permission
)
{
return
this
.
permissions
.
contains
(
permission
)
||
this
.
permissions
.
contains
(
"*"
)
||
(
this
.
permissions
.
contains
(
"player"
)
||
this
.
permissions
.
contains
(
"player.*"
))
&&
permission
.
startsWith
(
"player."
)
||
(
this
.
permissions
.
contains
(
"server"
)
||
this
.
permissions
.
contains
(
"server.*"
))
&&
permission
.
startsWith
(
"server."
);
if
(
this
.
permissions
.
contains
(
permission
)
||
this
.
permissions
.
contains
(
"*"
))
{
return
true
;
}
String
[]
permissionParts
=
permission
.
split
(
"\\."
);
for
(
String
p
:
this
.
permissions
)
{
if
(
permissionMatchesWildcard
(
p
,
permissionParts
))
{
return
true
;
}
}
return
false
;
}
public
boolean
removePermission
(
String
permission
)
{
...
...
src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java
View file @
2e69a4d8
...
...
@@ -190,6 +190,7 @@ public class StaminaManager {
// Returns new stamina and sends PlayerPropNotify
public
int
setStamina
(
GameSession
session
,
String
reason
,
int
newStamina
)
{
if
(
Grasscutter
.
getConfig
().
OpenStamina
)
{
// set stamina
player
.
setProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
,
newStamina
);
session
.
send
(
new
PacketPlayerPropNotify
(
player
,
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
));
...
...
@@ -199,6 +200,8 @@ public class StaminaManager {
}
return
newStamina
;
}
return
player
.
getProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
);
}
// Kills avatar, removes entity and sends notification.
// TODO: Probably move this to Avatar class? since other components may also need to kill avatar.
...
...
@@ -243,16 +246,17 @@ public class StaminaManager {
cachedEntity
=
entity
;
MotionInfo
motionInfo
=
moveInfo
.
getMotionInfo
();
MotionState
motionState
=
motionInfo
.
getState
();
boolean
isReliable
=
moveInfo
.
getIsReliable
();
Grasscutter
.
getLogger
().
trace
(
""
+
motionState
+
"\t"
+
(
isReliable
?
"reliable"
:
""
));
if
(
isReliable
)
{
int
notifyEntityId
=
entity
.
getId
();
int
currentAvatarEntityId
=
session
.
getPlayer
().
getTeamManager
().
getCurrentAvatarEntity
().
getId
();
if
(
notifyEntityId
!=
currentAvatarEntityId
)
{
return
;
}
currentState
=
motionState
;
Vector
posVector
=
motionInfo
.
getPos
();
Position
newPos
=
new
Position
(
posVector
.
getX
(),
posVector
.
getY
(),
posVector
.
getZ
());
if
(
newPos
.
getX
()
!=
0
&&
newPos
.
getY
()
!=
0
&&
newPos
.
getZ
()
!=
0
)
{
currentCoordinates
=
newPos
;
}
}
startSustainedStaminaHandler
();
handleImmediateStamina
(
session
,
motionInfo
,
motionState
,
entity
);
}
...
...
@@ -287,7 +291,6 @@ public class StaminaManager {
private
class
SustainedStaminaHandler
extends
TimerTask
{
public
void
run
()
{
if
(
Grasscutter
.
getConfig
().
OpenStamina
)
{
boolean
moving
=
isPlayerMoving
();
int
currentStamina
=
player
.
getProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
);
int
maxStamina
=
player
.
getProperty
(
PlayerProperty
.
PROP_MAX_STAMINA
);
...
...
@@ -332,7 +335,6 @@ public class StaminaManager {
updateStaminaRelative
(
cachedSession
,
consumption
);
}
}
}
previousState
=
currentState
;
previousCoordinates
=
new
Position
(
currentCoordinates
.
getX
(),
...
...
src/main/java/emu/grasscutter/scripts/service/ScriptMonsterTideService.java
View file @
2e69a4d8
...
...
@@ -79,6 +79,9 @@ public class ScriptMonsterTideService {
// fix the 5-2
sceneScriptManager
.
callEvent
(
EventType
.
EVENT_MONSTER_TIDE_DIE
,
new
ScriptArgs
(
monsterKillCount
.
get
()));
}
// spawn the last turn of monsters
// fix the 5-2
this
.
sceneScriptManager
.
callEvent
(
EventType
.
EVENT_MONSTER_TIDE_DIE
,
new
ScriptArgs
(
this
.
monsterKillCount
.
get
()));
}
public
void
unload
(){
...
...
src/main/resources/languages/en-US.json
View file @
2e69a4d8
...
...
@@ -334,6 +334,13 @@
},
"restart"
:
{
"description"
:
"Restarts the current session"
},
"unlocktower"
:
{
"success"
:
"unlock done"
,
"description"
:
"Unlock all levels of tower"
},
"resetshop"
:
{
"description"
:
"reset shop"
}
}
}
src/main/resources/languages/pl-PL.json
View file @
2e69a4d8
...
...
@@ -184,7 +184,7 @@
"account_error"
:
"Konto nie może zostać znalezione."
},
"position"
:
{
"success"
:
"Koordynaty: %
.3f, %.3f, %.3f
\n
ID sceny: %
d
"
"success"
:
"Koordynaty: %
s, %s, %s
\n
ID sceny: %
s
"
},
"reload"
:
{
"reload_start"
:
"Ponowne ładowanie konfiguracji."
,
...
...
@@ -293,6 +293,13 @@
"usage"
:
"Użycie: "
,
"aliases"
:
"Aliasy: "
,
"available_commands"
:
"Dostępne komendy: "
},
"unlocktower"
:
{
"success"
:
"odblokować gotowe"
,
"description"
:
"Odblokuj głęboką spiralę"
},
"resetshop"
:
{
"description"
:
"zresetuj sklep"
}
}
}
\ No newline at end of file
src/main/resources/languages/zh-CN.json
View file @
2e69a4d8
...
...
@@ -201,7 +201,7 @@
"description"
:
"给予或移除指定玩家的权限。"
},
"position"
:
{
"success"
:
"坐标:%
.3f, %.3f, %.3f
\n
场景ID:%
d
"
,
"success"
:
"坐标:%
s, %s, %s
\n
场景ID:%
s
"
,
"description"
:
"获取所在位置。"
},
"reload"
:
{
...
...
@@ -249,7 +249,7 @@
"setFetterLevel"
:
{
"usage"
:
"用法:setfetterlevel <level>"
,
"range_error"
:
"好感度等级必须在 0 到 10 之间。"
,
"
fetter_set_level
"
:
"好感度已设置为 %s 级"
,
"
success
"
:
"好感度已设置为 %s 级"
,
"level_error"
:
"无效的好感度等级。"
,
"description"
:
"设置当前角色的好感度等级。"
},
...
...
@@ -330,6 +330,13 @@
},
"restart"
:
{
"description"
:
"重新启动服务器。"
},
"unlocktower"
:
{
"success"
:
"解锁完成。"
,
"description"
:
"解锁深境螺旋的所有层"
},
"resetshop"
:
{
"description"
:
"重置商店时间"
}
}
}
src/main/resources/languages/zh-TW.json
View file @
2e69a4d8
...
...
@@ -184,7 +184,7 @@
"account_error"
:
"The account cannot be found."
},
"position"
:
{
"success"
:
"坐標:%
.3f, %.3f, %.3f
\n
場景ID:%
d
"
"success"
:
"坐標:%
s, %s, %s
\n
場景ID:%
s
"
},
"reload"
:
{
"reload_start"
:
"正在重新加載設定檔。"
,
...
...
@@ -226,7 +226,7 @@
"setFetterLevel"
:
{
"usage"
:
"用法:setfetterlevel <level>"
,
"range_error"
:
"好感度必須在 0 到 10 之間。"
,
"
fetter_set_level
"
:
"好感等級已設定為 %s"
,
"
success
"
:
"好感等級已設定為 %s"
,
"level_error"
:
"無效的好感度。"
},
"setStats"
:
{
...
...
@@ -293,6 +293,13 @@
"usage"
:
"用法:"
,
"aliases"
:
"別名:"
,
"available_commands"
:
"可用指令:"
},
"unlocktower"
:
{
"success"
:
"解鎖完成。"
,
"description"
:
"解鎖所有級別的深境螺旋"
},
"resetshop"
:
{
"description"
:
"重置商店時間"
}
}
}
Prev
1
2
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