-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More cleanups * Use index instead of table.insert * Address comments
- Loading branch information
1 parent
445dbc7
commit 5dbe68f
Showing
24 changed files
with
528 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function HandleNumChunksCommand(Split, Player) | ||
-- List each world's chunk count into a table, sum the total chunk count: | ||
local Response = {} | ||
local Total = 0 | ||
|
||
local GetWorldChunks = function(World) | ||
local numchunks = World:GetNumChunks() | ||
table.insert(Response, World:GetName() .. ": " .. numchunks .. " chunks") | ||
Total = Total + numchunks | ||
end | ||
|
||
table.insert(Response, "Number of loaded chunks:") | ||
cRoot:Get():ForEachWorld(GetWorldChunks) | ||
table.sort(Response) | ||
|
||
table.insert(Response, "Total: " .. Total .. " chunks") | ||
|
||
-- Return the complete report: | ||
return true, SendMessage(Player, table.concat(Response, "\n")) | ||
end | ||
|
||
function HandleConsoleNumChunks(Split) | ||
return HandleNumChunksCommand(Split) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function HandlePlayersCommand(Split, Player) | ||
local Response = {} | ||
|
||
local AddToResponse = function(OtherPlayer) | ||
table.insert(Response, " " .. OtherPlayer:GetName() .. " @ " .. OtherPlayer:GetIP()) | ||
end | ||
|
||
local ForEachPlayer = function(World) | ||
table.insert(Response, "World " .. World:GetName() .. ":") | ||
World:ForEachPlayer(AddToResponse) | ||
end | ||
|
||
table.insert(Response, "Players online:") | ||
cRoot:Get():ForEachWorld(ForEachPlayer) | ||
|
||
return true, SendMessage(Player, table.concat(Response, "\n")) | ||
end | ||
|
||
function HandleConsolePlayers(Split) | ||
return HandlePlayersCommand(Split) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function HandlePortalCommand(Split, Player) | ||
local WorldName = Split[2] | ||
|
||
if Split[3] then | ||
SendMessage(Player, "Usage: " .. Split[1] .. " [world]") | ||
elseif not WorldName then | ||
SendMessage(Player, "You are in world \"" .. Player:GetWorld():GetName() .. "\"") | ||
elseif Player:GetWorld():GetName() == WorldName then | ||
SendMessageFailure(Player, "You are already in world \"" .. Split[2] .. "\"!") | ||
elseif not cRoot:Get():GetWorld(WorldName) then | ||
SendMessageFailure(Player, "Could not find world \"" .. Split[2] .. "\"!") | ||
elseif not Player:MoveToWorld(WorldName) then | ||
SendMessageFailure(Player, "Could not move to world \"" .. Split[2] .. "\"!") | ||
else | ||
SendMessageSuccess(Player, "Successfully moved to world \"" .. Split[2] .. "\"! :D") | ||
end | ||
|
||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
local LastSender = {} | ||
|
||
function HandleTellCommand(Split, Player) | ||
local Response | ||
|
||
local SenderName = "Server" | ||
local SenderUUID = "CuberiteServerConsoleSender" | ||
|
||
if Player then | ||
SenderName = Player:GetName() | ||
SenderUUID = Player:GetUUID() | ||
end | ||
|
||
local SendPrivateMessage = function(OtherPlayer) | ||
local Message = table.concat(Split, " ", 2) | ||
|
||
local ReceiverName = "Server" | ||
local ReceiverUUID = "CuberiteServerConsoleSender" | ||
|
||
if OtherPlayer then | ||
ReceiverName = OtherPlayer:GetName() | ||
ReceiverUUID = OtherPlayer:GetUUID() | ||
|
||
OtherPlayer:SendMessagePrivateMsg(Message, SenderName) | ||
else | ||
LOG("[MSG:" .. SenderName .. "] " .. Message) | ||
end | ||
LastSender[ReceiverUUID] = SenderUUID | ||
|
||
Response = SendMessageSuccess(Player, "Message to \"" .. ReceiverName .. "\" sent!") | ||
end | ||
|
||
if Split[1] == "r" or Split[1] == "/r" then | ||
if not Split[2] then | ||
Response = SendMessage(Player, "Usage: " .. Split[1] .. " <message ...>") | ||
elseif not LastSender[SenderUUID] then | ||
Response = SendMessageFailure(Player, "No last sender found") | ||
elseif "CuberiteServerConsoleSender" == LastSender[SenderUUID] then | ||
SendPrivateMessage() | ||
else | ||
local ReceiverName = cMojangAPI:GetPlayerNameFromUUID(LastSender[SenderUUID], true) | ||
if not cRoot:Get():FindAndDoWithPlayer(ReceiverName, SendPrivateMessage) then | ||
Response = SendMessageFailure(Player, "Player \"" .. ReceiverName .. "\" not found") | ||
end | ||
end | ||
else | ||
if not Split[3] then | ||
Response = SendMessage(Player, "Usage: " .. Split[1] .. " <player> <message ...>") | ||
elseif Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], SendPrivateMessage) then | ||
Response = SendMessageFailure(Player, "Player \"" .. Split[2] .. "\" not found") | ||
end | ||
end | ||
return true, Response | ||
end | ||
|
||
function HandleConsoleTell(Split) | ||
return HandleTellCommand(Split) | ||
end | ||
|
||
function HandleRCommand(Split, Player) | ||
return HandleTellCommand(Split, Player) | ||
end | ||
|
||
function HandleConsoleR(Split) | ||
return HandleRCommand(Split) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.