Moved the commands /coords /viewdistance and /regeneratechunks from cServer.cpp to the Core plugin
git-svn-id: http://mc-server.googlecode.com/svn/trunk@457 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
2b0dd758d5
commit
ae3fa2b622
4
Plugins/Core/coords.lua
Normal file
4
Plugins/Core/coords.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function HandleCoordsCommand( Split, Player )
|
||||||
|
Player:SendMessage(cChatColor.Green .. string.format("[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
|
||||||
|
return true
|
||||||
|
end
|
@ -37,6 +37,9 @@ function Initialize( Plugin )
|
|||||||
Plugin:AddCommand("/top", " - Teleport yourself to the top most block", "core.top")
|
Plugin:AddCommand("/top", " - Teleport yourself to the top most block", "core.top")
|
||||||
Plugin:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm")
|
Plugin:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm")
|
||||||
Plugin:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld")
|
Plugin:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld")
|
||||||
|
Plugin:AddCommand("/coords", " - Show your current server coordinates", "core.coords")
|
||||||
|
Plugin:AddCommand("/viewdistance", " - [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance", "core.viewdistance")
|
||||||
|
Plugin:AddCommand("/regeneratechunk", " - <X [Z]> - Regenerates a chunk", "core.regeneratechunk")
|
||||||
|
|
||||||
Plugin:BindCommand( "/help", "core.help", HandleHelpCommand )
|
Plugin:BindCommand( "/help", "core.help", HandleHelpCommand )
|
||||||
Plugin:BindCommand( "/pluginlist", "core.pluginlist", HandlePluginListCommand )
|
Plugin:BindCommand( "/pluginlist", "core.pluginlist", HandlePluginListCommand )
|
||||||
@ -57,6 +60,9 @@ function Initialize( Plugin )
|
|||||||
Plugin:BindCommand( "/top", "core.top", HandleTopCommand )
|
Plugin:BindCommand( "/top", "core.top", HandleTopCommand )
|
||||||
Plugin:BindCommand( "/gm", "core.changegm", HandleChangeGMCommand )
|
Plugin:BindCommand( "/gm", "core.changegm", HandleChangeGMCommand )
|
||||||
Plugin:BindCommand( "/gotoworld", "core.gotoworld", HandleGotoWorldCommand )
|
Plugin:BindCommand( "/gotoworld", "core.gotoworld", HandleGotoWorldCommand )
|
||||||
|
Plugin:BindCommand( "/coords", "core.coords", HandleCoordsCommand )
|
||||||
|
Plugin:BindCommand( "/viewdistance","core.viewdistance", HandleViewDistanceCommand )
|
||||||
|
Plugin:BindCommand( "/regeneratechunk","core.regeneratechunk", HandleRegenerateChunkCommand )
|
||||||
|
|
||||||
|
|
||||||
local IniFile = cIniFile("settings.ini")
|
local IniFile = cIniFile("settings.ini")
|
||||||
|
18
Plugins/Core/regeneratechunk.lua
Normal file
18
Plugins/Core/regeneratechunk.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
function HandleRegenerateChunkCommand( Split, Player )
|
||||||
|
if( (#Split == 2) or (#Split > 3) ) then
|
||||||
|
Player:SendMessage( cChatColor.Green .. "Usage: /regeneratechunk <X [Z]>" )
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local X = Player:GetChunkX()
|
||||||
|
local Z = Player:GetChunkZ()
|
||||||
|
|
||||||
|
if( #Split == 3 ) then
|
||||||
|
X = Split[2]
|
||||||
|
Z = Split[3]
|
||||||
|
end
|
||||||
|
|
||||||
|
Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]")
|
||||||
|
Player:GetWorld():RegenerateChunk(X, Z)
|
||||||
|
return true
|
||||||
|
end
|
10
Plugins/Core/viewdistance.lua
Normal file
10
Plugins/Core/viewdistance.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
function HandleViewDistanceCommand( Split, Player )
|
||||||
|
if( #Split ~= 2 ) then
|
||||||
|
Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" )
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
Player:GetClientHandle():SetViewDistance( Split[2] )
|
||||||
|
Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() )
|
||||||
|
return true
|
||||||
|
end
|
@ -13,6 +13,7 @@
|
|||||||
#include "cPlayer.h"
|
#include "cPlayer.h"
|
||||||
#include "cWebAdmin.h"
|
#include "cWebAdmin.h"
|
||||||
#include "cStringMap.h"
|
#include "cStringMap.h"
|
||||||
|
#include "cClientHandle.h"
|
||||||
#include "md5/md5.h"
|
#include "md5/md5.h"
|
||||||
|
|
||||||
|
|
||||||
@ -507,6 +508,11 @@ void ManualBindings::Bind( lua_State* tolua_S )
|
|||||||
tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
|
tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
|
||||||
tolua_endmodule(tolua_S);
|
tolua_endmodule(tolua_S);
|
||||||
|
|
||||||
|
tolua_beginmodule(tolua_S,"cClientHandle");
|
||||||
|
tolua_constant(tolua_S,"MIN_VIEW_DISTANCE",cClientHandle::MIN_VIEW_DISTANCE);
|
||||||
|
tolua_constant(tolua_S,"MAX_VIEW_DISTANCE",cClientHandle::MAX_VIEW_DISTANCE);
|
||||||
|
tolua_endmodule(tolua_S);
|
||||||
|
|
||||||
tolua_function(tolua_S,"md5",tolua_md5);
|
tolua_function(tolua_S,"md5",tolua_md5);
|
||||||
|
|
||||||
tolua_endmodule(tolua_S);
|
tolua_endmodule(tolua_S);
|
||||||
|
@ -106,6 +106,7 @@ public:
|
|||||||
inline short GetPing() const { return m_Ping; } //tolua_export
|
inline short GetPing() const { return m_Ping; } //tolua_export
|
||||||
|
|
||||||
void SetViewDistance(int a_ViewDistance); //tolua_export
|
void SetViewDistance(int a_ViewDistance); //tolua_export
|
||||||
|
int GetViewDistance() { return m_ViewDistance; }//tolua_export
|
||||||
|
|
||||||
int GetUniqueID() const { return m_UniqueID; } //tolua_export
|
int GetUniqueID() const { return m_UniqueID; } //tolua_export
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ public: //tolua_export
|
|||||||
float GetRoll (void) const {return m_Rot.z; } //tolua_export
|
float GetRoll (void) const {return m_Rot.z; } //tolua_export
|
||||||
Vector3f GetLookVector(); //tolua_export
|
Vector3f GetLookVector(); //tolua_export
|
||||||
|
|
||||||
int GetChunkX(void) const {return m_ChunkX; }
|
int GetChunkX(void) const {return m_ChunkX; } //tolua_export
|
||||||
int GetChunkY(void) const {return m_ChunkY; }
|
int GetChunkY(void) const {return m_ChunkY; } //tolua_export
|
||||||
int GetChunkZ(void) const {return m_ChunkZ; }
|
int GetChunkZ(void) const {return m_ChunkZ; } //tolua_export
|
||||||
|
|
||||||
void SetPosX( const double & a_PosX ); //tolua_export
|
void SetPosX( const double & a_PosX ); //tolua_export
|
||||||
void SetPosY( const double & a_PosY ); //tolua_export
|
void SetPosY( const double & a_PosY ); //tolua_export
|
||||||
|
@ -464,66 +464,6 @@ bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Command( a_Cmd );
|
|
||||||
if( Command.length() <= 0 ) return false;
|
|
||||||
if( Command[0] != '/' ) return false;
|
|
||||||
|
|
||||||
AStringVector split = StringSplit( Command, " " );
|
|
||||||
if( split.size() == 0 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (split[0].compare("/coords") == 0)
|
|
||||||
{
|
|
||||||
AString Pos;
|
|
||||||
Printf(Pos, "[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", a_Client.GetPlayer()->GetPosX(), a_Client.GetPlayer()->GetPosY(), a_Client.GetPlayer()->GetPosZ() );
|
|
||||||
a_Client.Send( cPacket_Chat(cChatColor::Green + Pos));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (split[0].compare("/viewdistance") == 0)
|
|
||||||
{
|
|
||||||
if (split.size() != 2)
|
|
||||||
{
|
|
||||||
a_Client.Send(cPacket_Chat(cChatColor::Green + "Invalid syntax, expected 1 parameter, the number of chunks to stream"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int dist = atol(split[1].c_str());
|
|
||||||
a_Client.SetViewDistance(dist);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (split[0].compare("/regeneratechunk") == 0)
|
|
||||||
{
|
|
||||||
if (!a_Client.GetPlayer()->HasPermission("builtin.regeneratechunk"))
|
|
||||||
{
|
|
||||||
a_Client.Send(cPacket_Chat(cChatColor::Green + "You don't have permissions to regenerate chunks"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int ChunkX, ChunkZ;
|
|
||||||
if (split.size() == 1)
|
|
||||||
{
|
|
||||||
// Regenerate current chunk
|
|
||||||
ChunkX = a_Client.GetPlayer()->GetChunkX();
|
|
||||||
ChunkZ = a_Client.GetPlayer()->GetChunkZ();
|
|
||||||
}
|
|
||||||
else if (split.size() == 3)
|
|
||||||
{
|
|
||||||
// Regenerate chunk in params
|
|
||||||
ChunkX = atoi(split[1].c_str());
|
|
||||||
ChunkZ = atoi(split[2].c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
a_Client.Send(cPacket_Chat(cChatColor::Green + "Invalid syntax, expected either 0 (current chunk) or 2 (x, z) parameters"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
AString Msg;
|
|
||||||
Printf(Msg, "Regenerating chunk [%d, %d]", ChunkX, ChunkZ);
|
|
||||||
a_Client.Send(cPacket_Chat(cChatColor::Green + Msg));
|
|
||||||
a_Client.GetPlayer()->GetWorld()->RegenerateChunk(ChunkX, ChunkZ);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public:
|
|||||||
void ChunksStay(const cChunkCoordsList & a_Chunks, bool a_Stay = true);
|
void ChunksStay(const cChunkCoordsList & a_Chunks, bool a_Stay = true);
|
||||||
|
|
||||||
/// Regenerate the given chunk:
|
/// Regenerate the given chunk:
|
||||||
void RegenerateChunk(int a_ChunkX, int a_ChunkZ);
|
void RegenerateChunk(int a_ChunkX, int a_ChunkZ); //tolua_export
|
||||||
|
|
||||||
// TODO: Export to Lua
|
// TODO: Export to Lua
|
||||||
bool DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback );
|
bool DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback );
|
||||||
|
Loading…
Reference in New Issue
Block a user