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
dcd3c696
Commit
dcd3c696
authored
Jun 22, 2022
by
AnimeGitB
Browse files
Add default Climates per weather
parent
4df068bb
Changes
11
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/WeatherCommand.java
View file @
dcd3c696
package
emu.grasscutter.command.commands
;
package
emu.grasscutter.command.commands
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.game.props.ClimateType
;
import
emu.grasscutter.
server.packet.send.PacketSceneAreaWeatherNotify
;
import
emu.grasscutter.
game.world.Scene
;
import
java.util.List
;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"weather"
,
usage
=
"weather [weatherId] [climateType]"
,
aliases
=
{
"w"
},
permission
=
"player.weather"
,
permissionTargeted
=
"player.weather.others"
,
description
=
"commands.weather.description"
)
@Command
(
label
=
"weather"
,
usage
=
"weather <climate type(weatherId)> <weather type(climateId)>"
,
aliases
=
{
"w"
},
permission
=
"player.weather"
,
permissionTargeted
=
"player.weather.others"
,
description
=
"commands.weather.description"
)
public
final
class
WeatherCommand
implements
CommandHandler
{
public
final
class
WeatherCommand
implements
CommandHandler
{
@Override
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
int
weatherId
=
0
;
Scene
scene
=
targetPlayer
.
getScene
()
;
int
climateId
=
1
;
int
weatherId
=
scene
.
getWeather
()
;
switch
(
args
.
size
())
{
ClimateType
climate
=
ClimateType
.
CLIMATE_NONE
;
// Sending ClimateType.CLIMATE_NONE to Scene.setWeather will use the default climate for that weather
case
2
:
try
{
if
(
args
.
isEmpty
())
{
climate
Id
=
Integer
.
parseInt
(
args
.
get
(
1
)
);
climate
=
scene
.
getClimate
(
);
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendTranslatedMessage
(
sender
,
"commands.weather.status"
,
Integer
.
toString
(
weatherId
),
climate
.
getShortName
());
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.weather.invalid_id"
))
;
return
;
}
}
case
1
:
for
(
String
arg
:
args
)
{
ClimateType
c
=
ClimateType
.
getTypeByShortName
(
arg
.
toLowerCase
());
if
(
c
!=
ClimateType
.
CLIMATE_NONE
)
{
climate
=
c
;
}
else
{
try
{
try
{
weatherId
=
Integer
.
parseInt
(
arg
s
.
get
(
0
)
);
weatherId
=
Integer
.
parseInt
(
arg
);
}
catch
(
NumberFormatException
ignored
)
{
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.weather.invalid_id"
));
CommandHandler
.
sendTranslatedMessage
(
sender
,
"commands.generic.invalid.id"
);
}
CommandHandler
.
sendTranslatedMessage
(
sender
,
"commands.weather.usage"
);
break
;
default
:
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.weather.usage"
));
return
;
return
;
}
}
}
}
ClimateType
climate
=
ClimateType
.
getTypeByValue
(
climateId
);
scene
.
setWeather
(
weatherId
,
climate
);
climate
=
scene
.
getClimate
();
// Might be different to what we set
targetPlayer
.
getScene
().
setWeather
(
weatherId
);
CommandHandler
.
sendTranslatedMessage
(
sender
,
"commands.weather.success"
,
Integer
.
toString
(
weatherId
),
climate
.
getShortName
());
targetPlayer
.
getScene
().
setClimate
(
climate
);
targetPlayer
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
targetPlayer
));
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.weather.success"
,
Integer
.
toString
(
weatherId
),
Integer
.
toString
(
climateId
)));
}
}
}
}
src/main/java/emu/grasscutter/data/GameData.java
View file @
dcd3c696
...
@@ -94,6 +94,7 @@ public class GameData {
...
@@ -94,6 +94,7 @@ public class GameData {
private
static
final
Int2ObjectMap
<
FurnitureMakeConfigData
>
furnitureMakeConfigDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FurnitureMakeConfigData
>
furnitureMakeConfigDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
InvestigationMonsterData
>
investigationMonsterDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
InvestigationMonsterData
>
investigationMonsterDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
CityData
>
cityDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
CityData
>
cityDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WeatherData
>
weatherDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
BattlePassMissionExcelConfigData
>
battlePassMissionExcelConfigDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
BattlePassMissionExcelConfigData
>
battlePassMissionExcelConfigDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
BattlePassRewardExcelConfigData
>
battlePassRewardExcelConfigDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
BattlePassRewardExcelConfigData
>
battlePassRewardExcelConfigDataMap
=
new
Int2ObjectOpenHashMap
<>();
...
@@ -414,10 +415,15 @@ public class GameData {
...
@@ -414,10 +415,15 @@ public class GameData {
public
static
Int2ObjectMap
<
InvestigationMonsterData
>
getInvestigationMonsterDataMap
()
{
public
static
Int2ObjectMap
<
InvestigationMonsterData
>
getInvestigationMonsterDataMap
()
{
return
investigationMonsterDataMap
;
return
investigationMonsterDataMap
;
}
}
public
static
Int2ObjectMap
<
CityData
>
getCityDataMap
()
{
public
static
Int2ObjectMap
<
CityData
>
getCityDataMap
()
{
return
cityDataMap
;
return
cityDataMap
;
}
}
public
static
Int2ObjectMap
<
WeatherData
>
getWeatherDataMap
()
{
return
weatherDataMap
;
}
public
static
Int2ObjectMap
<
BattlePassMissionExcelConfigData
>
getBattlePassMissionExcelConfigDataMap
()
{
public
static
Int2ObjectMap
<
BattlePassMissionExcelConfigData
>
getBattlePassMissionExcelConfigDataMap
()
{
return
battlePassMissionExcelConfigDataMap
;
return
battlePassMissionExcelConfigDataMap
;
}
}
...
...
src/main/java/emu/grasscutter/data/excels/WeatherData.java
0 → 100644
View file @
dcd3c696
package
emu.grasscutter.data.excels
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.props.ClimateType
;
import
lombok.Getter
;
@ResourceType
(
name
=
"WeatherExcelConfigData.json"
)
public
class
WeatherData
extends
GameResource
{
@Getter
private
int
areaID
;
@Getter
private
int
weatherAreaId
;
@Getter
private
String
maxHeightStr
;
@Getter
private
int
gadgetID
;
@Getter
private
boolean
isDefaultValid
;
@Getter
private
String
templateName
;
@Getter
private
int
priority
;
@Getter
private
String
profileName
;
@Getter
private
ClimateType
defaultClimate
;
@Getter
private
boolean
isUseDefault
;
@Getter
private
int
sceneID
;
@Override
public
int
getId
()
{
return
this
.
areaID
;
}
}
src/main/java/emu/grasscutter/game/props/ClimateType.java
View file @
dcd3c696
...
@@ -32,7 +32,11 @@ public enum ClimateType {
...
@@ -32,7 +32,11 @@ public enum ClimateType {
}
}
public
int
getValue
()
{
public
int
getValue
()
{
return
value
;
return
this
.
value
;
}
public
String
getShortName
()
{
return
this
.
name
().
substring
(
8
).
toLowerCase
();
}
}
public
static
ClimateType
getTypeByValue
(
int
value
)
{
public
static
ClimateType
getTypeByValue
(
int
value
)
{
...
@@ -42,4 +46,9 @@ public enum ClimateType {
...
@@ -42,4 +46,9 @@ public enum ClimateType {
public
static
ClimateType
getTypeByName
(
String
name
)
{
public
static
ClimateType
getTypeByName
(
String
name
)
{
return
stringMap
.
getOrDefault
(
name
,
CLIMATE_NONE
);
return
stringMap
.
getOrDefault
(
name
,
CLIMATE_NONE
);
}
}
public
static
ClimateType
getTypeByShortName
(
String
shortName
)
{
String
name
=
"CLIMATE_"
+
shortName
.
toUpperCase
();
return
stringMap
.
getOrDefault
(
name
,
CLIMATE_NONE
);
}
}
}
src/main/java/emu/grasscutter/game/world/Scene.java
View file @
dcd3c696
...
@@ -138,12 +138,30 @@ public class Scene {
...
@@ -138,12 +138,30 @@ public class Scene {
return
weather
;
return
weather
;
}
}
public
void
setClimate
(
ClimateType
climate
)
{
synchronized
public
void
setClimate
(
ClimateType
climate
)
{
this
.
climate
=
climate
;
this
.
climate
=
climate
;
for
(
Player
player
:
this
.
players
)
{
this
.
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
player
));
}
}
synchronized
public
void
setWeather
(
int
weather
)
{
this
.
setWeather
(
weather
,
ClimateType
.
CLIMATE_NONE
);
}
}
public
void
setWeather
(
int
weather
)
{
synchronized
public
void
setWeather
(
int
weather
,
ClimateType
climate
)
{
// Lookup default climate for this weather
if
(
climate
==
ClimateType
.
CLIMATE_NONE
)
{
WeatherData
w
=
GameData
.
getWeatherDataMap
().
get
(
weather
);
if
(
w
!=
null
)
{
climate
=
w
.
getDefaultClimate
();
}
}
this
.
weather
=
weather
;
this
.
weather
=
weather
;
this
.
climate
=
climate
;
for
(
Player
player
:
this
.
players
)
{
this
.
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
player
));
}
}
}
public
int
getPrevScene
()
{
public
int
getPrevScene
()
{
...
...
src/main/resources/languages/en-US.json
View file @
dcd3c696
...
@@ -76,7 +76,8 @@
...
@@ -76,7 +76,8 @@
"itemLevel"
:
"Invalid itemLevel."
,
"itemLevel"
:
"Invalid itemLevel."
,
"itemRefinement"
:
"Invalid itemRefinement."
,
"itemRefinement"
:
"Invalid itemRefinement."
,
"playerId"
:
"Invalid player ID."
,
"playerId"
:
"Invalid player ID."
,
"uid"
:
"Invalid UID."
"uid"
:
"Invalid UID."
,
"id"
:
"Invalid ID."
}
}
},
},
"execution"
:
{
"execution"
:
{
...
@@ -387,10 +388,10 @@
...
@@ -387,10 +388,10 @@
"description"
:
"Unlock all levels of tower"
"description"
:
"Unlock all levels of tower"
},
},
"weather"
:
{
"weather"
:
{
"
usage"
:
"Usage: weather <climate type(weatherId)> <weather type(climateId)>
\n
Weather types 0: None, 1: S
unny,
2: C
loudy,
3: R
ain,
4: T
hunderstorm,
5: S
now,
6: M
ist"
,
"
description"
:
"Changes the weather. Climate types s
unny,
c
loudy,
r
ain,
t
hunderstorm,
s
now,
m
ist
.
"
,
"
success"
:
"Changed
climate
t
ype
to %s with weather type %s
."
,
"
usage"
:
"Usage: weather [weatherId] [
climate
T
ype
]
\n
Climate types sunny, cloudy, rain, thunderstorm, snow, mist
."
,
"
invalid_id"
:
"Invalid ID
."
,
"
success"
:
"Set weather ID to %s with climate type %s
."
,
"
description"
:
"Changes the weather
"
"
status"
:
"Current weather ID is %s with climate type %s.
"
},
},
"ban"
:
{
"ban"
:
{
"description"
:
"Ban a player"
,
"description"
:
"Ban a player"
,
...
...
src/main/resources/languages/fr-FR.json
View file @
dcd3c696
...
@@ -76,7 +76,8 @@
...
@@ -76,7 +76,8 @@
"itemLevel"
:
"Niveau de l'objet invalide."
,
"itemLevel"
:
"Niveau de l'objet invalide."
,
"itemRefinement"
:
"Raffinement de l'objet invalide."
,
"itemRefinement"
:
"Raffinement de l'objet invalide."
,
"playerId"
:
"ID du joueur invalide."
,
"playerId"
:
"ID du joueur invalide."
,
"uid"
:
"UID invalide."
"uid"
:
"UID invalide."
,
"id"
:
"ID invalide."
}
}
},
},
"execution"
:
{
"execution"
:
{
...
@@ -387,10 +388,10 @@
...
@@ -387,10 +388,10 @@
"description"
:
"Débloque tous les couloirs de l'abysse"
"description"
:
"Débloque tous les couloirs de l'abysse"
},
},
"weather"
:
{
"weather"
:
{
"
usage"
:
"Usage: weather <climate type(weatherId)> <weather type(climateId)>
\n
Types de météo 0: Aucun, 1: Ensoleillé, 2: Nuageux, 3: Pluvieux, 4: Orageux, 5: Neige, 6: Brouillard
"
,
"
description"
:
"Change la météo. Climate types sunny, cloudy, rain, thunderstorm, snow, mist.
"
,
"
success"
:
"Le type de climat a été changé à %s avec le type de météo %s
."
,
"
usage"
:
"Utilisation: weather [weatherId] [climateType]
\n
Climate types sunny, cloudy, rain, thunderstorm, snow, mist
."
,
"
invalid_id"
:
"ID invalide
."
,
"
success"
:
"Set weather ID to %s with climate type %s
."
,
"
description"
:
"Change la météo
"
"
status"
:
"Current weather ID is %s with climate type %s.
"
},
},
"ban"
:
{
"ban"
:
{
"description"
:
"Bannis un joueur"
,
"description"
:
"Bannis un joueur"
,
...
...
src/main/resources/languages/pl-PL.json
View file @
dcd3c696
...
@@ -70,7 +70,8 @@
...
@@ -70,7 +70,8 @@
"itemLevel"
:
"Błędny poziom przedmiotu."
,
"itemLevel"
:
"Błędny poziom przedmiotu."
,
"itemRefinement"
:
"Błędne ulepszenie."
,
"itemRefinement"
:
"Błędne ulepszenie."
,
"playerId"
:
"Błędne playerId."
,
"playerId"
:
"Błędne playerId."
,
"uid"
:
"Błędne UID."
"uid"
:
"Błędne UID."
,
"id"
:
"Błędne ID."
}
}
},
},
"execution"
:
{
"execution"
:
{
...
@@ -291,9 +292,10 @@
...
@@ -291,9 +292,10 @@
"success"
:
"Przeteleportowano %s do %s, %s, %s w scenie %s"
"success"
:
"Przeteleportowano %s do %s, %s, %s w scenie %s"
},
},
"weather"
:
{
"weather"
:
{
"usage"
:
"Użycie: weather <climate type(weatherId)> <weather type(climateId)>
\n
Weather types 0: None, 1: Sunny, 2: Cloudy, 3: Rain, 4: Thunderstorm, 5: Snow, 6: Mist"
,
"description"
:
"Changes the weather. Climate types sunny, cloudy, rain, thunderstorm, snow, mist."
,
"success"
:
"Changed climate type to %s with weather type %s."
,
"usage"
:
"Usage: weather [weatherId] [climateType]
\n
Climate types sunny, cloudy, rain, thunderstorm, snow, mist."
,
"invalid_id"
:
"Błędne ID."
"success"
:
"Set weather ID to %s with climate type %s."
,
"status"
:
"Current weather ID is %s with climate type %s."
},
},
"drop"
:
{
"drop"
:
{
"command_usage"
:
"Użycie: drop <ID przedmiotu|nazwa przedmiotu> [ilość]"
,
"command_usage"
:
"Użycie: drop <ID przedmiotu|nazwa przedmiotu> [ilość]"
,
...
...
src/main/resources/languages/ru-RU.json
View file @
dcd3c696
...
@@ -76,7 +76,8 @@
...
@@ -76,7 +76,8 @@
"itemLevel"
:
"Некорректный уровень предмета (itemLevel)."
,
"itemLevel"
:
"Некорректный уровень предмета (itemLevel)."
,
"itemRefinement"
:
"Некорректный уровень пробуждения предмета (itemRefinement)."
,
"itemRefinement"
:
"Некорректный уровень пробуждения предмета (itemRefinement)."
,
"playerId"
:
"Некорректный ID игрока."
,
"playerId"
:
"Некорректный ID игрока."
,
"uid"
:
"Некорректный UID."
"uid"
:
"Некорректный UID."
,
"id"
:
"Некорректный ID."
}
}
},
},
"execution"
:
{
"execution"
:
{
...
@@ -387,10 +388,10 @@
...
@@ -387,10 +388,10 @@
"description"
:
"Открывает все уровни башни"
"description"
:
"Открывает все уровни башни"
},
},
"weather"
:
{
"weather"
:
{
"
usage"
:
"Применение: weather <тип_климата(Id погоды)> <тип_погоды(Id климата)>
\n
Типы погоды 0: Отсутствует, 1: Солнечная, 2: Пасмурная, 3: Дождливая, 4: Грозовая, 5: Снежная, 6: Туманная
"
,
"
description"
:
"Изменяет погоду. Climate types sunny, cloudy, rain, thunderstorm, snow, mist.
"
,
"
success"
:
"Тип климата был изменен на %s, тип погоды: %s
."
,
"
usage"
:
"Usage: weather [weatherId] [climateType]
\n
Climate types sunny, cloudy, rain, thunderstorm, snow, mist
."
,
"
invalid_id"
:
"Некорректный ID
."
,
"
success"
:
"Set weather ID to %s with climate type %s
."
,
"
description"
:
"Изменяет погоду
"
"
status"
:
"Current weather ID is %s with climate type %s.
"
},
},
"ban"
:
{
"ban"
:
{
"description"
:
"Банит игрока"
,
"description"
:
"Банит игрока"
,
...
...
src/main/resources/languages/zh-CN.json
View file @
dcd3c696
...
@@ -76,7 +76,8 @@
...
@@ -76,7 +76,8 @@
"itemLevel"
:
"无效的物品等级。"
,
"itemLevel"
:
"无效的物品等级。"
,
"itemRefinement"
:
"无效的物品精炼等级。"
,
"itemRefinement"
:
"无效的物品精炼等级。"
,
"playerId"
:
"无效的玩家ID。"
,
"playerId"
:
"无效的玩家ID。"
,
"uid"
:
"无效的UID。"
"uid"
:
"无效的UID。"
,
"id"
:
"无效的ID。"
}
}
},
},
"execution"
:
{
"execution"
:
{
...
@@ -387,10 +388,10 @@
...
@@ -387,10 +388,10 @@
"description"
:
"解锁深境螺旋"
"description"
:
"解锁深境螺旋"
},
},
"weather"
:
{
"weather"
:
{
"
usage"
:
"用法:weather <气候类型(天气ID)> <天气类型(气候ID)>
\n
天气类型 0: 无, 1: 晴天, 2: 多云, 3: 雨, 4: 雷雨, 5: 雪, 6: 雾
"
,
"
description"
:
"更改天气. Climate types sunny, cloudy, rain, thunderstorm, snow, mist.
"
,
"
success"
:
"已更改气候类型为 %s,天气类型为 %s。
"
,
"
usage"
:
"用法:weather [weatherId] [climateType]
\n
Climate types sunny (晴天), cloudy (多云), rain (雨), thunderstorm (雷雨), snow (雪), mist (雾).
"
,
"
invalid_id"
:
"无效的ID。
"
,
"
success"
:
"Set weather ID to %s with climate type %s.
"
,
"
description"
:
"更改天气
"
"
status"
:
"Current weather ID is %s with climate type %s.
"
},
},
"ban"
:
{
"ban"
:
{
"description"
:
"封禁玩家"
,
"description"
:
"封禁玩家"
,
...
...
src/main/resources/languages/zh-TW.json
View file @
dcd3c696
...
@@ -75,7 +75,8 @@
...
@@ -75,7 +75,8 @@
"itemLevel"
:
"無效的物品等級。"
,
"itemLevel"
:
"無效的物品等級。"
,
"itemRefinement"
:
"無效的物品精煉度。"
,
"itemRefinement"
:
"無效的物品精煉度。"
,
"playerId"
:
"無效的玩家ID。"
,
"playerId"
:
"無效的玩家ID。"
,
"uid"
:
"無效的UID。"
"uid"
:
"無效的UID。"
,
"id"
:
"無效的ID。"
}
}
},
},
"execution"
:
{
"execution"
:
{
...
@@ -390,10 +391,10 @@
...
@@ -390,10 +391,10 @@
"description"
:
"解鎖所有級別的深境螺旋。"
"description"
:
"解鎖所有級別的深境螺旋。"
},
},
"weather"
:
{
"weather"
:
{
"
usage"
:
"用法:weather <氣候型別(weatherId)> <天氣型別(climateId)>
\n
天氣類型: '0:無、 1:晴天、 2:多雲、 3:雨、 4::雷雨、 5:雪、 6:霧'
"
,
"
description"
:
"更改目前的天氣。. Climate types sunny, cloudy, rain, thunderstorm, snow, mist.
"
,
"
success"
:
"已將當前氣候設定為 %s ,天氣則為 %s 。
"
,
"
usage"
:
"用法:weather [weatherId] [climateType]
\n
Climate types sunny (晴天), cloudy (多雲), rain (雨), thunderstorm (雷雨), snow (雪), mist (霧).
"
,
"
invalid_id"
:
"無效的ID。
"
,
"
success"
:
"Set weather ID to %s with climate type %s.
"
,
"
description"
:
"更改目前的天氣。
"
"
status"
:
"Current weather ID is %s with climate type %s.
"
},
},
"ban"
:
{
"ban"
:
{
"description"
:
"停權指定玩家。"
,
"description"
:
"停權指定玩家。"
,
...
...
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