aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Server/Console/commands/weather
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Server/Console/commands/weather')
-rw-r--r--Minecraft.Server/Console/commands/weather/CliCommandWeather.cpp49
-rw-r--r--Minecraft.Server/Console/commands/weather/CliCommandWeather.h15
2 files changed, 64 insertions, 0 deletions
diff --git a/Minecraft.Server/Console/commands/weather/CliCommandWeather.cpp b/Minecraft.Server/Console/commands/weather/CliCommandWeather.cpp
new file mode 100644
index 00000000..e7f01954
--- /dev/null
+++ b/Minecraft.Server/Console/commands/weather/CliCommandWeather.cpp
@@ -0,0 +1,49 @@
+#include "stdafx.h"
+
+#include "CliCommandWeather.h"
+
+#include "..\..\ServerCliEngine.h"
+#include "..\..\ServerCliParser.h"
+#include "..\..\..\..\Minecraft.World\GameCommandPacket.h"
+#include "..\..\..\..\Minecraft.World\ToggleDownfallCommand.h"
+
+namespace ServerRuntime
+{
+ namespace
+ {
+ constexpr const char *kWeatherUsage = "weather";
+ }
+
+ const char *CliCommandWeather::Name() const
+ {
+ return "weather";
+ }
+
+ const char *CliCommandWeather::Usage() const
+ {
+ return kWeatherUsage;
+ }
+
+ const char *CliCommandWeather::Description() const
+ {
+ return "Toggle weather via Minecraft.World command dispatcher.";
+ }
+
+ bool CliCommandWeather::Execute(const ServerCliParsedLine &line, ServerCliEngine *engine)
+ {
+ if (line.tokens.size() != 1)
+ {
+ engine->LogWarn(std::string("Usage: ") + kWeatherUsage);
+ return false;
+ }
+
+ std::shared_ptr<GameCommandPacket> packet = ToggleDownfallCommand::preparePacket();
+ if (packet == nullptr)
+ {
+ engine->LogError("Failed to build weather command packet.");
+ return false;
+ }
+
+ return engine->DispatchWorldCommand(packet->command, packet->data);
+ }
+}
diff --git a/Minecraft.Server/Console/commands/weather/CliCommandWeather.h b/Minecraft.Server/Console/commands/weather/CliCommandWeather.h
new file mode 100644
index 00000000..03498b47
--- /dev/null
+++ b/Minecraft.Server/Console/commands/weather/CliCommandWeather.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "..\IServerCliCommand.h"
+
+namespace ServerRuntime
+{
+ class CliCommandWeather : public IServerCliCommand
+ {
+ public:
+ const char *Name() const override;
+ const char *Usage() const override;
+ const char *Description() const override;
+ bool Execute(const ServerCliParsedLine &line, ServerCliEngine *engine) override;
+ };
+}