From 176deb4b5bbbfc23e44bb4d5087c7832cad36da1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 6 Apr 2014 22:30:34 +0200 Subject: Added the generated ZBS API file to ignore list. --- MCServer/.gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to 'MCServer') diff --git a/MCServer/.gitignore b/MCServer/.gitignore index 69826ef06..32a634a03 100644 --- a/MCServer/.gitignore +++ b/MCServer/.gitignore @@ -28,3 +28,5 @@ motd.txt *.deuser *.dmp *.xml +mcserver_api.lua + -- cgit v1.2.3 From 8c7d0f53041af5b5e5b4e42902e6ac49abbd5bd7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 7 Apr 2014 15:47:42 +0200 Subject: InfoReg uses cCompositeChat for subcommand lists. Also fixed an issue with console commands. --- MCServer/Plugins/InfoReg.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/InfoReg.lua b/MCServer/Plugins/InfoReg.lua index 27e63aa5b..da5a9972c 100644 --- a/MCServer/Plugins/InfoReg.lua +++ b/MCServer/Plugins/InfoReg.lua @@ -16,22 +16,22 @@ local function ListSubcommands(a_Player, a_Subcommands, a_CmdString) end -- Enum all the subcommands: - local Verbs = {}; + local Verbs = {} for cmd, info in pairs(a_Subcommands) do - if (a_Player:HasPermission(info.Permission or "")) then - table.insert(Verbs, " " .. a_CmdString .. " " .. cmd); + if ((a_Player == nil) or (a_Player:HasPermission(info.Permission or ""))) then + table.insert(Verbs, a_CmdString .. " " .. cmd) end end - table.sort(Verbs); + table.sort(Verbs) -- Send the list: if (a_Player == nil) then for idx, verb in ipairs(Verbs) do - LOGINFO(verb); + LOGINFO(" " .. verb) end else for idx, verb in ipairs(Verbs) do - a_Player:SendMessage(verb); + a_Player:SendMessage(cCompositeChat(" ", mtInfo):AddSuggestCommandPart(verb, verb)) end end end -- cgit v1.2.3 From 62991d46fed9b5a7b181a2ef165935784d572b06 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Apr 2014 16:15:57 +0200 Subject: APIDump: Added a ChunkStay article. Fixes #772. --- MCServer/Plugins/APIDump/APIDesc.lua | 7 +- MCServer/Plugins/APIDump/UsingChunkStays.html | 167 ++++++++++++++++++++++++++ MCServer/Plugins/APIDump/WebWorldThreads.html | 48 ++++---- 3 files changed, 195 insertions(+), 27 deletions(-) create mode 100644 MCServer/Plugins/APIDump/UsingChunkStays.html (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 233bdbc46..45e8d9677 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2929,9 +2929,10 @@ end { -- No sorting is provided for these, they will be output in the same order as defined here { FileName = "Writing-a-MCServer-plugin.html", Title = "Writing a MCServer plugin" }, - { FileName = "SettingUpDecoda.html", Title = "Setting up the Decoda Lua IDE" }, - { FileName = "SettingUpZeroBrane.html", Title = "Setting up the ZeroBrane Studio Lua IDE" }, - { FileName = "WebWorldThreads.html", Title = "Webserver vs World threads" }, + { FileName = "SettingUpDecoda.html", Title = "Setting up the Decoda Lua IDE" }, + { FileName = "SettingUpZeroBrane.html", Title = "Setting up the ZeroBrane Studio Lua IDE" }, + { FileName = "UsingChunkStays.html", Title = "Using ChunkStays" }, + { FileName = "WebWorldThreads.html", Title = "Webserver vs World threads" }, } } ; diff --git a/MCServer/Plugins/APIDump/UsingChunkStays.html b/MCServer/Plugins/APIDump/UsingChunkStays.html new file mode 100644 index 000000000..d3ecc6674 --- /dev/null +++ b/MCServer/Plugins/APIDump/UsingChunkStays.html @@ -0,0 +1,167 @@ + + + + MCServer - Using ChunkStays + + + + + + + +
+

Using ChunkStays

+

+ A plugin may need to manipulate data in arbitrary chunks, and it needs a way to make the server + guarantee that the chunks are available in memory.

+ +

The problem

+

+ Usually when plugins want to manipulate larger areas of world data, they need to make sure that the + server has the appropriate chunks loaded in the memory. When the data being manipulated can be further + away from the connected players, or the data is being manipulated from a console handler, there is a + real chance that the chunks are not loaded.

+

+ This gets even more important when using the cBlockArea class for reading + and writing. Those functions will fail when any of the required chunks aren't valid. This means that + either the block area has incomplete data (Read() failed) or incomplete data has been written to the + world (Write() failed). Recovery from this is near impossible - you can't simply read or write again + later, because the world may have changed in the meantime.

+ +

The solution

+

+ The naive solution would be to monitor chunk loads and unloads, and postpone the operations until all + the chunks are available. This would be quite ineffective and also very soon it would become very + difficult to maintain, if there were multiple code paths requiring this handling.

+

+ An alternate approach has been implemented, accessible through a single (somewhat hidden) function + call: cWorld:ChunkStay(). All that this call basically does is, it tells the + server "Load these chunks for me, and call this callback function once you have them all." And the + server does exactly that - it remembers the callback and asks the world loader / generator to provide + the chunks. Once the chunks become available, it calls the callback function for the plugin.

+

+ There are a few gotcha-s, though. If the code that was requesting the read or write had access to some + of the volatile objects, such as cPlayer or + cEntity objects, those cannot be accessed by the callback anymore, because + they may have become invalid in the meantime - the player may have disconnected, the entity may have + despawned. So the callback must use the longer way to access such objects, such as calling + cWorld:DoWithEntityByID() or + cWorld:DoWithPlayer().

+ +

The example

+

+ As a simple example, consider a theoretical plugin that allows a player to save the immediate + surroundings of the spawn into a schematic file. The player issues a command to initiate the save, and + the plugin reads a 50 x 50 x 50 block area around the spawn into a cBlockArea and saves it on the disk + as "_spawn.schematic". When it's done with the saving, it wants to send a message to the + player to let them know the command has succeeded.

+

+ The first attempt shows the naive approach. It simply reads the block area and saves it, then sends the + message. I'll repeat once more, this code is the wrong way to do it!

+
+function HandleCommandSaveSpawn(a_Split, a_Player)
+	-- Get the coords for the spawn:
+	local SpawnX = a_Player:GetWorld():GetSpawnX()
+	local SpawnY = a_Player:GetWorld():GetSpawnY()
+	local SpawnZ = a_Player:GetWorld():GetSpawnZ()
+	local Bounds = cCuboid(SpawnX - 25, SpawnY - 25, SpawnZ - 25, SpawnX + 25, SpawnY + 25, SpawnZ + 25)
+	Bounds:ClampY(0, 255)
+	
+	-- Read the area around spawn into a cBlockArea, save to file:
+	local Area = cBlockArea()
+	local FileName = a_Player:GetName() .. "_spawn.schematic"
+	Area:Read(a_Player:GetWorld(), Bounds, cBlockArea.baTypes + cBlockArea.baMetas)
+	Area:SaveToSchematicFile(FileName)
+	
+	-- Notify the player:
+	a_Player:SendMessage(cCompositeChat("The spawn has been saved", mtInfo))
+	return true
+end
+
+

+ Now if the player goes exploring far and uses the command to save their spawn, the chunks aren't + loaded, so the BlockArea reading fails, the BlockArea contains bad data. Note that the plugin fails to + do any error checking and if the area isn't read from the world, it happily saves the incomplete data + and says "hey, everything's right", althought it has just trashed any previous backup of the spawn + schematic with nonsense data.

+
+

+ The following script uses the ChunkStay method to alleviate chunk-related problems. This is the + right way of doing it:

+
+function HandleCommandSaveSpawn(a_Split, a_Player)
+	-- Get the coords for the spawn:
+	local SpawnX = a_Player:GetWorld():GetSpawnX()
+	local SpawnY = a_Player:GetWorld():GetSpawnY()
+	local SpawnZ = a_Player:GetWorld():GetSpawnZ()
+	local Bounds = cCuboid(SpawnX - 25, SpawnY - 25, SpawnZ - 25, SpawnX + 25, SpawnY + 25, SpawnZ + 25)
+	Bounds:ClampY(0, 255)
+	
+	-- Get a list of chunks that we need loaded:
+	local MinChunkX = math.floor((SpawnX - 25) / 16)
+	local MaxChunkX = math.ceil ((SpawnX + 25) / 16)
+	local MinChunkZ = math.floor((SpawnZ - 25) / 16)
+	local MaxChunkZ = math.ceil ((SpawnZ + 25) / 16)
+	local Chunks = {}
+	for x = MinChunkX, MaxChunkX do
+		for z = MinChunkZ, MaxChunkZ do
+			table.insert(Chunks, {x, z})
+		end
+	end  -- for x
+	
+	-- Store the player's name and world to use in the callback, because the a_Player object may no longer be valid:
+	local PlayerName = a_Player:GetName()
+	local World = a_Player:GetWorld()
+	
+	-- This is the callback that is executed once all the chunks are loaded:
+	local OnAllChunksAvailable = function()
+		-- Read the area around spawn into a cBlockArea, save to file:
+		local Area = cBlockArea()
+		local FileName = PlayerName .. "_spawn.schematic"
+		if (Area:Read(World, Bounds, cBlockArea.baTypes + cBlockArea.baMetas)) then
+			Area:SaveToSchematicFile(FileName)
+			Msg = cCompositeChat("The spawn has been saved", mtInfo)
+		else
+			Msg = cCompositeChat("Cannot save the spawn", mtFailure)
+		end
+		
+		-- Notify the player:
+		-- Note that we cannot use a_Player here, because it may no longer be valid (if the player disconnected before the command completes)
+		World:DoWithPlayer(PlayerName,
+			function (a_CBPlayer)
+				a_CBPlayer:SendMessage(Msg)
+			end
+		)
+	end
+	
+	-- Ask the server to load our chunks and notify us once it's done:
+	World:ChunkStay(Chunks, nil, OnAllChunksAvailable)
+	
+	-- Note that code here may get executed before the callback is called!
+	-- The ChunkStay says "once you have the chunks", not "wait until you have the chunks"
+	-- So you can't notify the player here, because the saving needn't have occurred yet.
+	
+	return true
+end
+
+

+ Note that this code does its error checking of the Area:Read() function, and it will not overwrite the + previous file unless it actually has the correct data. If you're wondering how the reading could fail + when we've got the chunks loaded, there's still the issue of free RAM - if the memory for the area + cannot be allocated, it cannot be read even with all the chunks present. So we still do need that + check.

+ +

The conclusion

+

+ Although it makes the code a little bit longer and is a bit more difficult to grasp at first, the + ChunkStay is a useful technique to add to your repertoire. It is to be used whenever you need access to + chunks that may potentially be inaccessible, and you really need the data.

+

Possibly the biggest hurdle in using the ChunkStay is the fact that it does its work in the + background, thus invalidating all cPlayer and cEntity objects your function may hold, so you need to + re-acquire them from their IDs and names. This is the penalty for using multi-threaded code.

+ +
+ + diff --git a/MCServer/Plugins/APIDump/WebWorldThreads.html b/MCServer/Plugins/APIDump/WebWorldThreads.html index fc80a6178..ee0b172e6 100644 --- a/MCServer/Plugins/APIDump/WebWorldThreads.html +++ b/MCServer/Plugins/APIDump/WebWorldThreads.html @@ -39,31 +39,31 @@

Example

The Core has the facility to kick players using the web interface. It used the following code for the kicking (inside the webadmin handler): -
-			local KickPlayerName = Request.Params["players-kick"]
-			local FoundPlayerCallback = function(Player)
-			  if (Player:GetName() == KickPlayerName) then
-				Player:GetClientHandle():Kick("You were kicked from the game!")
-			  end
+
+local KickPlayerName = Request.Params["players-kick"]
+local FoundPlayerCallback = function(Player)
+	if (Player:GetName() == KickPlayerName) then
+	Player:GetClientHandle():Kick("You were kicked from the game!")
+	end
+end
+cRoot:Get():FindAndDoWithPlayer(KickPlayerName, FoundPlayerCallback)
+
+The cRoot:FindAndDoWithPlayer() is unsafe and could have caused a deadlock. The new solution is queue a task; but since we don't know in which world the player is, we need to queue the task to all worlds: +
+cRoot:Get():ForEachWorld(    -- For each world...
+	function(World)
+	World:QueueTask(         -- ... queue a task...
+		function(a_World)
+		a_World:DoWithPlayer(KickPlayerName,  -- ... to walk the playerlist...
+			function (a_Player)
+			a_Player:GetClientHandle():Kick("You were kicked from the game!")  -- ... and kick the player
 			end
-			cRoot:Get():FindAndDoWithPlayer(KickPlayerName, FoundPlayerCallback)
-			
- The cRoot:FindAndDoWithPlayer() is unsafe and could have caused a deadlock. The new solution is queue a task; but since we don't know in which world the player is, we need to queue the task to all worlds: -
-			cRoot:Get():ForEachWorld(    -- For each world...
-			  function(World)
-				World:QueueTask(         -- ... queue a task...
-				  function(a_World)
-					a_World:DoWithPlayer(KickPlayerName,  -- ... to walk the playerlist...
-					  function (a_Player)
-						a_Player:GetClientHandle():Kick("You were kicked from the game!")  -- ... and kick the player
-					  end
-					)
-				  end
-				)
-			  end
-			)
-			
+ ) + end + ) + end +) +
-- cgit v1.2.3 From 1cf396c814e2f4586f55b13130a9f7a039caed4c Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Apr 2014 02:18:41 -1000 Subject: Fixed capitalization issues Wasn't parsing correctly before, as some items were not capitalized correctly. --- MCServer/monsters.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer') diff --git a/MCServer/monsters.ini b/MCServer/monsters.ini index 8cd956157..cd5d92b66 100644 --- a/MCServer/monsters.ini +++ b/MCServer/monsters.ini @@ -47,7 +47,7 @@ AttackDamage=4.0 SightDistance=25.0 MaxHealth=40 -[Zombiepigman] +[ZombiePigman] AttackRange=2.0 AttackRate=1 AttackDamage=7.0 @@ -145,7 +145,7 @@ AttackDamage=0.0 SightDistance=25.0 MaxHealth=10 -[Magmacube] +[MagmaCube] AttackRange=2.0 AttackRate=1 AttackDamage=6.0 -- cgit v1.2.3 From e1476ebb26a3ce0b8405feb5a530cb442abd1329 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Apr 2014 13:17:42 -1000 Subject: Added IsFireproof hook for monsters.ini --- MCServer/monsters.ini | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MCServer') diff --git a/MCServer/monsters.ini b/MCServer/monsters.ini index cd5d92b66..8da3d6d24 100644 --- a/MCServer/monsters.ini +++ b/MCServer/monsters.ini @@ -4,6 +4,7 @@ AttackRate=1 AttackDamage=2.0 SightDistance=25.0 MaxHealth=16 +IsFireproof=0 [Chicken] AttackRange=2.0 @@ -11,6 +12,7 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=4 +IsFireproof=0 [Cow] AttackRange=2.0 @@ -18,6 +20,7 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=10 +IsFireproof=0 [Pig] AttackRange=2.0 @@ -25,6 +28,7 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=10 +IsFireproof=0 [Sheep] AttackRange=2.0 @@ -32,6 +36,7 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=8 +IsFireproof=0 [Squid] AttackRange=2.0 @@ -39,6 +44,7 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=10 +IsFireproof=0 [Enderman] AttackRange=2.0 @@ -46,6 +52,7 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=40 +IsFireproof=0 [ZombiePigman] AttackRange=2.0 @@ -53,6 +60,7 @@ AttackRate=1 AttackDamage=7.0 SightDistance=25.0 MaxHealth=20 +IsFireproof=1 [Cavespider] AttackRange=2.0 @@ -60,6 +68,7 @@ AttackRate=1 AttackDamage=2.0 SightDistance=25.0 MaxHealth=12 +IsFireproof=0 [Creeper] AttackRange=3.0 @@ -67,6 +76,7 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=20 +IsFireproof=0 [Ghast] AttackRange=50.0 @@ -74,6 +84,7 @@ AttackRate=1 AttackDamage=0.0 SightDistance=50.0 MaxHealth=10 +IsFireproof=1 [Silverfish] AttackRange=2.0 @@ -81,12 +92,14 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=8 +IsFireproof=0 [Skeleton] AttackRange=15.0 AttackRate=1 SightDistance=40.0 MaxHealth=20 +IsFireproof=0 [Slime] AttackRange=2.0 @@ -94,6 +107,7 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=16 +IsFireproof=0 [Zombie] AttackRange=2.0 @@ -101,6 +115,7 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=20 +IsFireproof=0 [Wolf] AttackRange=2.0 @@ -108,6 +123,7 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=20 +IsFireproof=0 [Blaze] AttackRange=15.0 @@ -115,6 +131,7 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=20 +IsFireproof=1 [Villager] AttackRange=2.0 @@ -122,6 +139,7 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=20 +IsFireproof=0 [Witch] AttackRange=2.0 @@ -129,6 +147,7 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=26 +IsFireproof=0 [Ocelot] @@ -137,6 +156,7 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=10 +IsFireproof=0 [Mooshroom] AttackRange=2.0 @@ -144,6 +164,7 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=10 +IsFireproof=0 [MagmaCube] AttackRange=2.0 @@ -151,6 +172,7 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=16 +IsFireproof=1 [Horse] AttackRange=2.0 @@ -158,6 +180,7 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=30 +IsFireproof=0 [EnderDragon] AttackRange=2.0 @@ -165,6 +188,7 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=200 +IsFireproof=0 [Giant] AttackRange=2.0 @@ -172,6 +196,7 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=100 +IsFireproof=0 [IronGolem] AttackRange=2.0 @@ -179,5 +204,6 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=100 +IsFireproof=0 -- cgit v1.2.3 From fe08a903fcf47fc7e3748d24ac6beb592908553a Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Apr 2014 15:45:52 -1000 Subject: Declaration that a mob is not fireproof is implicit. Removed explicitly declaring mobs as not fireproof. --- MCServer/monsters.ini | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'MCServer') diff --git a/MCServer/monsters.ini b/MCServer/monsters.ini index 8da3d6d24..fa376bfff 100644 --- a/MCServer/monsters.ini +++ b/MCServer/monsters.ini @@ -4,7 +4,6 @@ AttackRate=1 AttackDamage=2.0 SightDistance=25.0 MaxHealth=16 -IsFireproof=0 [Chicken] AttackRange=2.0 @@ -12,7 +11,6 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=4 -IsFireproof=0 [Cow] AttackRange=2.0 @@ -20,7 +18,6 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=10 -IsFireproof=0 [Pig] AttackRange=2.0 @@ -28,7 +25,6 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=10 -IsFireproof=0 [Sheep] AttackRange=2.0 @@ -36,7 +32,6 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=8 -IsFireproof=0 [Squid] AttackRange=2.0 @@ -44,7 +39,6 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=10 -IsFireproof=0 [Enderman] AttackRange=2.0 @@ -52,7 +46,6 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=40 -IsFireproof=0 [ZombiePigman] AttackRange=2.0 @@ -68,7 +61,6 @@ AttackRate=1 AttackDamage=2.0 SightDistance=25.0 MaxHealth=12 -IsFireproof=0 [Creeper] AttackRange=3.0 @@ -76,7 +68,6 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=20 -IsFireproof=0 [Ghast] AttackRange=50.0 @@ -92,14 +83,12 @@ AttackRate=1 AttackDamage=1.0 SightDistance=25.0 MaxHealth=8 -IsFireproof=0 [Skeleton] AttackRange=15.0 AttackRate=1 SightDistance=40.0 MaxHealth=20 -IsFireproof=0 [Slime] AttackRange=2.0 @@ -107,7 +96,6 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=16 -IsFireproof=0 [Zombie] AttackRange=2.0 @@ -115,7 +103,6 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=20 -IsFireproof=0 [Wolf] AttackRange=2.0 @@ -123,7 +110,6 @@ AttackRate=1 AttackDamage=4.0 SightDistance=25.0 MaxHealth=20 -IsFireproof=0 [Blaze] AttackRange=15.0 @@ -147,7 +133,6 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=26 -IsFireproof=0 [Ocelot] @@ -156,7 +141,6 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=10 -IsFireproof=0 [Mooshroom] AttackRange=2.0 @@ -164,7 +148,6 @@ AttackRate=1 AttackDamage=0.0 SightDistance=25.0 MaxHealth=10 -IsFireproof=0 [MagmaCube] AttackRange=2.0 @@ -180,7 +163,6 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=30 -IsFireproof=0 [EnderDragon] AttackRange=2.0 @@ -188,7 +170,6 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=200 -IsFireproof=0 [Giant] AttackRange=2.0 @@ -196,7 +177,6 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=100 -IsFireproof=0 [IronGolem] AttackRange=2.0 @@ -204,6 +184,5 @@ AttackRate=1 AttackDamage=6.0 SightDistance=25.0 MaxHealth=100 -IsFireproof=0 -- cgit v1.2.3 From 695baed22641aa420787d99cedae5aeb6d2938e7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Apr 2014 23:06:29 +0200 Subject: Updated docs for StringToEnchantmentID. Ref.: mc-server/Core#67 --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 45e8d9677..1423d64bc 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -699,7 +699,7 @@ end GetLevel = { Params = "EnchantmentNumID", Return = "number", Notes = "Returns the level of the specified enchantment stored in this object; 0 if not stored" }, IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if the object stores no enchantments" }, SetLevel = { Params = "EnchantmentNumID, Level", Return = "", Notes = "Sets the level for the specified enchantment, adding it if not stored before or removing it if level < = 0" }, - StringToEnchantmentID = { Params = "EnchantmentTextID", Return = "number", Notes = "(static) Returns the enchantment numerical ID, -1 if not understood. Case insensitive" }, + StringToEnchantmentID = { Params = "EnchantmentTextID", Return = "number", Notes = "(static) Returns the enchantment numerical ID, -1 if not understood. Case insensitive. Also understands plain numbers." }, ToString = { Params = "", Return = "string", Notes = "Returns the string description of all the enchantments stored in this object, in numerical-ID form" }, }, Constants = -- cgit v1.2.3 From 06819595b0a5366711bb4aa156a2198650e5c0ff Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 23 Apr 2014 15:25:10 -0700 Subject: Fixed references to renamed files. --- MCServer/monsters.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/monsters.ini b/MCServer/monsters.ini index fa376bfff..b631fc1a9 100644 --- a/MCServer/monsters.ini +++ b/MCServer/monsters.ini @@ -55,7 +55,7 @@ SightDistance=25.0 MaxHealth=20 IsFireproof=1 -[Cavespider] +[CaveSpider] AttackRange=2.0 AttackRate=1 AttackDamage=2.0 -- cgit v1.2.3 From 0cfa0c45610cbe5c7ae6a03034f81416699247c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 12:23:01 +0200 Subject: APIDump: Improved error handling in API file loader. --- MCServer/Plugins/APIDump/main_APIDump.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index 52199740b..a25bab9cf 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -27,10 +27,14 @@ local function LoadAPIFiles(a_Folder, a_DstTable) -- We only want .lua files from the folder: if (cFile:IsFile(FileName) and fnam:match(".*%.lua$")) then local TablesFn, Err = loadfile(FileName); - if (TablesFn == nil) then + if (type(TablesFn) ~= "function") then LOGWARNING("Cannot load API descriptions from " .. FileName .. ", Lua error '" .. Err .. "'."); else local Tables = TablesFn(); + if (type(Tables) ~= "table") then + LOGWARNING("Cannot load API descriptions from " .. FileName .. ", returned object is not a table (" .. type(Tables) .. ")."); + break + end for k, cls in pairs(Tables) do a_DstTable[k] = cls; end -- cgit v1.2.3 From 13452d3ab92c1cc12201caf60782fd7f7c4314f7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 12:23:22 +0200 Subject: APIDump: Updated the OnDisconnect hook docs. Ref.: #655. --- MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua b/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua index a3301a8c6..204cb63d2 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua @@ -2,23 +2,33 @@ return { HOOK_DISCONNECT = { - CalledWhen = "A player has explicitly disconnected.", + CalledWhen = [[ + A client has disconnected, either by explicitly sending the disconnect packet (in older protocols) or + their connection was terminated + ]], DefaultFnName = "OnDisconnect", -- also used as pagename Desc = [[ - This hook is called when a client is about to be disconnected from the server, for whatever reason. - -

Note that this hook will be removed after <1.7 protocol support is removed, as it was originally a hook for - the client sending the server a disconnect packet, which no longer happens.

+ This hook is called when a client has disconnected from the server, for whatever reason. It is also + called when the client sends the Disconnect packet (only in pre-1.7 protocols). This hook is not called + for server ping connections.

+

+ Note that the hook is called even for connections to players who failed to auth. In such a case there's + no {{cPlayer}} object associated with the client.

+

+ See also the {{OnHandshake|HOOK_HANDSHAKE}} hook which is called when the client connects (and presents + a handshake message, so that they are not just status-pinging). If you need to store a per-player + object, use the {{OnPlayerJoined|HOOK_PLAYER_JOINED}} and {{OnPlayerDestroyed|HOOK_PLAYER_DESTROYED}} + hooks instead, those are guaranteed to have the {{cPlayer}} object associated. ]], Params = { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has disconnected" }, + { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client who has disconnected" }, { Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" }, }, Returns = [[ If the function returns false or no value, MCServer calls other plugins' callbacks for this event. If the function returns true, no other plugins are called for this event. In either case, - the player is disconnected. + the client is disconnected. ]], }, -- HOOK_DISCONNECT } -- cgit v1.2.3