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
500580f3
Commit
500580f3
authored
Apr 20, 2022
by
Yazawazi
Committed by
GitHub
Apr 20, 2022
Browse files
Add /weather Command
parent
86694158
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/commands/PlayerCommands.java
View file @
500580f3
...
@@ -16,10 +16,12 @@ import emu.grasscutter.game.entity.EntityMonster;
...
@@ -16,10 +16,12 @@ import emu.grasscutter.game.entity.EntityMonster;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ActionReason
;
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.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Position
;
...
@@ -536,4 +538,29 @@ public final class PlayerCommands {
...
@@ -536,4 +538,29 @@ public final class PlayerCommands {
}
}
}
}
}
}
@Command
(
label
=
"weather"
,
aliases
=
{
"weather"
,
"w"
},
usage
=
"weather <weather id>"
,
description
=
"Changes the weather."
,
execution
=
Command
.
Execution
.
PLAYER
,
permission
=
"player.weather"
)
public
static
class
ChangeWeatherCommand
implements
CommandHandler
{
@Override
public
void
execute
(
GenshinPlayer
player
,
List
<
String
>
args
)
{
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
player
,
"Usage: weather <weather id>"
);
return
;
}
try
{
int
weatherId
=
Integer
.
parseInt
(
args
.
get
(
0
));
ClimateType
climate
=
ClimateType
.
getTypeByValue
(
weatherId
);
player
.
getScene
().
setClimate
(
climate
);
player
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
player
));
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
player
,
"Invalid weather ID."
);
}
}
}
}
}
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