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
e5ff2536
Commit
e5ff2536
authored
Jul 22, 2022
by
Melledy
Browse files
Add `unlockall` command to unlock all openstates
parent
705bee05
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/UnlockAllCommand.java
0 → 100644
View file @
e5ff2536
package
emu.grasscutter.command.commands
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.OpenState
;
import
emu.grasscutter.server.packet.send.PacketOpenStateChangeNotify
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"unlockall"
,
usage
=
{
""
},
permission
=
"player.unlockall"
,
permissionTargeted
=
"player.unlockall.others"
)
public
final
class
UnlockAllCommand
implements
CommandHandler
{
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
Map
<
Integer
,
Integer
>
changed
=
new
HashMap
<>();
for
(
OpenState
state
:
OpenState
.
values
())
{
if
(
state
==
OpenState
.
OPEN_STATE_NONE
||
state
==
OpenState
.
OPEN_STATE_LIMIT_REGION_GLOBAL
)
continue
;
if
(
targetPlayer
.
getOpenStateManager
().
getOpenStateMap
().
getOrDefault
(
state
.
getValue
(),
0
)
==
0
)
{
targetPlayer
.
getOpenStateManager
().
getOpenStateMap
().
put
(
state
.
getValue
(),
1
);
changed
.
put
(
state
.
getValue
(),
1
);
}
}
targetPlayer
.
sendPacket
(
new
PacketOpenStateChangeNotify
(
changed
));
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.unlockall.success"
,
targetPlayer
.
getNickname
()));
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketOpenStateChangeNotify.java
View file @
e5ff2536
package
emu.grasscutter.server.packet.send
;
import
java.util.Map
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.OpenStateChangeNotifyOuterClass.OpenStateChangeNotify
;
...
...
@@ -11,7 +13,18 @@ public class PacketOpenStateChangeNotify extends BasePacket {
super
(
PacketOpcodes
.
OpenStateChangeNotify
);
OpenStateChangeNotify
proto
=
OpenStateChangeNotify
.
newBuilder
()
.
putOpenStateMap
(
openState
,
value
).
build
();
.
putOpenStateMap
(
openState
,
value
)
.
build
();
this
.
setData
(
proto
);
}
public
PacketOpenStateChangeNotify
(
Map
<
Integer
,
Integer
>
map
)
{
super
(
PacketOpcodes
.
OpenStateChangeNotify
);
OpenStateChangeNotify
proto
=
OpenStateChangeNotify
.
newBuilder
()
.
putAllOpenStateMap
(
map
)
.
build
();
this
.
setData
(
proto
);
}
...
...
src/main/resources/languages/en-US.json
View file @
e5ff2536
...
...
@@ -326,6 +326,10 @@
"invalid_time"
:
"Unable to parse timestamp."
,
"description"
:
"Ban a player"
},
"unlockall"
:
{
"success"
:
"Unlocked all open states for %s."
,
"description"
:
"Unlocks all open states for a player."
},
"unban"
:
{
"success"
:
"Successful."
,
"failure"
:
"Failed, player not found."
,
...
...
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