Skip to content

Commit

Permalink
Fixed type errors found with the CuberitePluginChecher.
Browse files Browse the repository at this point in the history
  • Loading branch information
madmaxoft committed Oct 6, 2016
1 parent 05d260f commit 4a15772
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
16 changes: 8 additions & 8 deletions functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ function TeleportToPlayer( a_SrcPlayer, a_DstPlayerName, a_TellDst )
-- Asked to teleport to self?
SendMessageFailure( a_SrcPlayer, "Y' can't teleport to yerself" )
else
-- If destination player is not in the same world, move to the correct world
if a_SrcPlayer:GetWorld():GetName() ~= a_DstPlayerName:GetWorld():GetName() then
a_SrcPlayer:MoveToWorld( a_DstPlayerName:GetWorld():GetName() )
-- If destination player is not in the same world, move to the correct world
if a_SrcPlayer:GetWorld():GetName() ~= a_DstPlayerName:GetWorld():GetName() then
a_SrcPlayer:MoveToWorld( a_DstPlayerName:GetWorld():GetName() )
end

a_SrcPlayer:TeleportToEntity( a_DstPlayerName )
Expand Down Expand Up @@ -137,7 +137,7 @@ function SetWorldDifficulty(a_World, a_Difficulty)
-- Update world.ini
local WorldIni = cIniFile()
WorldIni:ReadFile(a_World:GetIniFileName())
WorldIni:SetValue("Difficulty", "WorldDifficulty", Difficulty)
WorldIni:SetValueI("Difficulty", "WorldDifficulty", Difficulty)
WorldIni:WriteFile(a_World:GetIniFileName())
end

Expand All @@ -155,13 +155,13 @@ end
-- if no world of the given name is found, returns nil and informs the Player, if given, otherwise logs to console.
-- If no WorldName was given, returns the default world if called without a Player,
-- or the current world that the player is in if called with a Player.
--
--
-- @param WorldName String containing the name of the world to find
-- @param Player cPlayer object representing the player calling the command
--
--
-- @return cWorld object representing the requested world, or nil if not found
--
-- Called from: time.lua, weather.lua,
-- Called from: time.lua, weather.lua,
--
function GetWorld( WorldName, Player )

Expand All @@ -178,7 +178,7 @@ function GetWorld( WorldName, Player )
LOG( Message )
end
end

return World
end
end
38 changes: 19 additions & 19 deletions spawn.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function HandleSpawnCommand(Split, Player)

local WorldIni = cIniFile()
WorldIni:ReadFile(Player:GetWorld():GetIniFileName())
local SpawnX = WorldIni:GetValue("SpawnPosition", "X")
local SpawnY = WorldIni:GetValue("SpawnPosition", "Y")
local SpawnZ = WorldIni:GetValue("SpawnPosition", "Z")

local SpawnX = WorldIni:GetValueI("SpawnPosition", "X")
local SpawnY = WorldIni:GetValueI("SpawnPosition", "Y")
local SpawnZ = WorldIni:GetValueI("SpawnPosition", "Z")
local flag = 0

if (#Split == 2 and Split[2] ~= Player:GetName()) then
if Player:HasPermission("core.spawn.others") then
local FoundPlayerCallback = function(OtherPlayer)
Expand All @@ -18,11 +18,11 @@ function HandleSpawnCommand(Split, Player)
SendMessageSuccess( Player, "Returned " .. OtherPlayer:GetName() .. " to world spawn" )
flag=1
end
World:ChunkStay({{SpawnX/16, SpawnZ/16}}, OnChunkAvailable, OnAllChunksAvaliable)
World:ChunkStay({{SpawnX / 16, SpawnZ / 16}}, OnChunkAvailable, OnAllChunksAvaliable)
end
end
cRoot:Get():FindAndDoWithPlayer(Split[2], FoundPlayerCallback)

if flag == 0 then
SendMessageFailure( Player, "Player " .. Split[2] .. " not found!" )
end
Expand All @@ -35,32 +35,32 @@ function HandleSpawnCommand(Split, Player)
Player:TeleportToCoords(SpawnX, SpawnY, SpawnZ)
SendMessageSuccess( Player, "Returned to world spawn" )
end
World:ChunkStay({{SpawnX/16, SpawnZ/16}}, OnChunkAvailable, OnAllChunksAvaliable)
World:ChunkStay({{SpawnX / 16, SpawnZ / 16}}, OnChunkAvailable, OnAllChunksAvaliable)
end

return true

end

function HandleSetSpawnCommand(Split, Player)

local WorldIni = cIniFile()
WorldIni:ReadFile(Player:GetWorld():GetIniFileName())

local PlayerX = Player:GetPosX()
local PlayerY = Player:GetPosY()
local PlayerZ = Player:GetPosZ()

WorldIni:DeleteValue("SpawnPosition", "X")
WorldIni:DeleteValue("SpawnPosition", "Y")
WorldIni:DeleteValue("SpawnPosition", "Z")
WorldIni:SetValue("SpawnPosition", "X", PlayerX)
WorldIni:SetValue("SpawnPosition", "Y", PlayerY)
WorldIni:SetValue("SpawnPosition", "Z", PlayerZ)

WorldIni:SetValueI("SpawnPosition", "X", PlayerX)
WorldIni:SetValueI("SpawnPosition", "Y", PlayerY)
WorldIni:SetValueI("SpawnPosition", "Z", PlayerZ)
WorldIni:WriteFile(Player:GetWorld():GetIniFileName())

SendMessageSuccess( Player, string.format("Changed spawn position to [X:%i Y:%i Z:%i]", PlayerX, PlayerY, PlayerZ) )
return true

end
18 changes: 12 additions & 6 deletions viewdistance.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
function HandleViewDistanceCommand( Split, Player )
function HandleViewDistanceCommand(a_Split, a_Player)
-- Check the number of params, show usage if not enough:
if (#a_Split ~= 2) then
SendMessage(a_Player, "Usage: /viewdistance <".. cClientHandle.MIN_VIEW_DISTANCE .." - ".. cClientHandle.MAX_VIEW_DISTANCE ..">")
return true
end

if( #Split ~= 2 ) then
SendMessage( Player, "Usage: /viewdistance <".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE ..">" )
-- Check if the param is a number:
local viewDistance = tonumber(a_Split[2])
if not(viewDistance) then
SendMessageFailure(a_Player, "Expected a number parameter")
return true
end

Player:GetClientHandle():SetViewDistance( Split[2] )
SendMessageSuccess( Player, "Your view distance has been set to " .. Player:GetClientHandle():GetViewDistance() )
a_Player:GetClientHandle():SetViewDistance(viewDistance)
SendMessageSuccess(a_Player, "Your view distance is now " .. a_Player:GetClientHandle():GetViewDistance())
return true

end

0 comments on commit 4a15772

Please sign in to comment.