summaryrefslogtreecommitdiffstats
path: root/MCServer
diff options
context:
space:
mode:
Diffstat (limited to 'MCServer')
m---------MCServer/Plugins/ChatLog0
-rw-r--r--MCServer/Plugins/ChatLog/plugin.lua31
m---------MCServer/Plugins/ChunkWorx0
-rw-r--r--MCServer/Plugins/ChunkWorx/ChunkWorx.deproj9
-rw-r--r--MCServer/Plugins/ChunkWorx/chunkworx_main.lua128
-rw-r--r--MCServer/Plugins/ChunkWorx/chunkworx_web.lua274
m---------MCServer/Plugins/Handy0
-rw-r--r--MCServer/Plugins/Handy/handy.lua28
-rw-r--r--MCServer/Plugins/Handy/handy_functions.lua216
m---------MCServer/Plugins/MagicCarpet0
-rw-r--r--MCServer/Plugins/MagicCarpet/objects.lua97
-rw-r--r--MCServer/Plugins/MagicCarpet/plugin.lua81
12 files changed, 0 insertions, 864 deletions
diff --git a/MCServer/Plugins/ChatLog b/MCServer/Plugins/ChatLog
new file mode 160000
+Subproject 983d23ca37baa89f7e4dc11d71502d9c059f637
diff --git a/MCServer/Plugins/ChatLog/plugin.lua b/MCServer/Plugins/ChatLog/plugin.lua
deleted file mode 100644
index adbf986e0..000000000
--- a/MCServer/Plugins/ChatLog/plugin.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-
--- plugin.lua
-
--- Implements the main entrypoint for the plugin, as well as all the handling needed
-
--- ChatLog plugin logs all chat messages into the server log
-
-
-
-
-
-function Initialize(Plugin)
- Plugin:SetName("ChatLog")
- Plugin:SetVersion(3)
-
- cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat)
-
- LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
- return true
-end
-
-
-
-
-
-function OnChat(Player, Message)
- -- Lets get loggin'
- LOGINFO("[" .. Player:GetName() .. "]: " .. StripColorCodes(Message));
-
- return false
-end \ No newline at end of file
diff --git a/MCServer/Plugins/ChunkWorx b/MCServer/Plugins/ChunkWorx
new file mode 160000
+Subproject 894c7e32049e9d2a1e736f7d721aaacd1ae29e5
diff --git a/MCServer/Plugins/ChunkWorx/ChunkWorx.deproj b/MCServer/Plugins/ChunkWorx/ChunkWorx.deproj
deleted file mode 100644
index 17420d1d7..000000000
--- a/MCServer/Plugins/ChunkWorx/ChunkWorx.deproj
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<project>
- <file>
- <filename>chunkworx_main.lua</filename>
- </file>
- <file>
- <filename>chunkworx_web.lua</filename>
- </file>
-</project>
diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua
deleted file mode 100644
index 88ecb3979..000000000
--- a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua
+++ /dev/null
@@ -1,128 +0,0 @@
--- Global variables
-PLUGIN = {} -- Reference to own plugin object
-GENERATION_STATE = 0
-OPERATION_CODE = 0 -- 0 = generation
-CX = 0
-CZ = 0
-CURRENT = 0
-TOTAL = 0
-
--- AREA Variables
-AreaStartX = -10
-AreaStartZ = -10
-AreaEndX = 10
-AreaEndZ = 10
-
--- RADIAL Variables
-RadialX = 0
-RadialZ = 0
-Radius = 10
-
--- WORLD
-WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName()
-WW_instance = cRoot:Get():GetDefaultWorld()
-WORLDS = {}
-
-
-
-
-
-function Initialize(Plugin)
- PLUGIN = Plugin
-
- PLUGIN:SetName("ChunkWorx")
- PLUGIN:SetVersion(6)
-
- cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick)
-
- Plugin:AddWebTab("(Re)Generation", HandleRequest_Generation)
-
- GENERATION_STATE = 0
- WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
- if (WW_instance == nil) then
- LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
- end
-
- -- Read the stored values:
- local SettingsIni = cIniFile();
- SettingsIni:ReadFile("ChunkWorx.ini"); -- ignore any read errors
- AreaStartX = SettingsIni:GetValueSetI("Area data", "StartX", AreaStartX)
- AreaStartZ = SettingsIni:GetValueSetI("Area data", "StartZ", AreaStartZ)
- AreaEndX = SettingsIni:GetValueSetI("Area data", "EndX", AreaEndX)
- AreaEndZ = SettingsIni:GetValueSetI("Area data", "EndZ", AreaEndZ)
- RadialX = SettingsIni:GetValueSetI("Radial data", "RadialX", RadialX)
- RadialZ = SettingsIni:GetValueSetI("Radial data", "RadialZ", RadialZ)
- Radius = SettingsIni:GetValueSetI("Radial data", "Radius", Radius)
- SettingsIni:WriteFile("ChunkWorx.ini");
-
- LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
- return true
-end
-
-
-
-
-
-function OnTick( DeltaTime )
- if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then
- LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works STARTED!")
- LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": At world: " .. WORK_WORLD)
- WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
- if (GENERATION_STATE == 1) then GENERATION_STATE = 2 end
- if (GENERATION_STATE == 3) then GENERATION_STATE = 4 end
-
- -- Changing in case coordinates are flipped
- local shifter = AreaEndX
- if (AreaStartX > AreaEndX) then
- AreaEndX = AreaStartX
- AreaStartX = shifter
- end
- shifter = AreaEndZ
- if (AreaStartZ > AreaEndZ) then
- AreaEndZ = AreaStartZ
- AreaStartZ = shifter
- end
-
- CX = AreaStartX
- CZ = AreaStartZ
- CURRENT = 0
-
- if (WW_instance == nil) then
- LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED")
- LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
- GENERATION_STATE = 0
- end
- end
-
-
-
- if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
- if (WW_instance:GetGeneratorQueueLength() < 200
- and WW_instance:GetLightingQueueLength() < 200
- and (WW_instance:GetStorageSaveQueueLength() + WW_instance:GetStorageLoadQueueLength()) < 80) then
- local chunk_sum = (1+ AreaEndX - AreaStartX) * (1+ AreaEndZ - AreaStartZ)
- TOTAL = chunk_sum
- LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": PROCESSING 100 chunks, (" .. CURRENT .. "/" .. chunk_sum .. ")")
- for C = 1, 100 do
- if (GENERATION_STATE == 2) then WW_instance:GenerateChunk(CX, CZ) end
- if (GENERATION_STATE == 4) then WW_instance:RegenerateChunk(CX, CZ) end
-
- CX = CX + 1
- CURRENT = CURRENT + 1
- if (CX > AreaEndX) then
- CX = AreaStartX
- CZ = CZ + 1
- if (CZ > AreaEndZ) then
- if (GENERATION_STATE == 2) then LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " - generation ENDED!") end
- if (GENERATION_STATE == 4) then LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " - REgeneration ENDED!") end
-
- GENERATION_STATE = 0
- break
- end
- end
- end
- WW_instance:QueueSaveAllChunks()
- WW_instance:QueueUnloadUnusedChunks()
- end
- end
-end \ No newline at end of file
diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
deleted file mode 100644
index 9aec38b12..000000000
--- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
+++ /dev/null
@@ -1,274 +0,0 @@
-
--- chunkworx_web.lua
-
--- WebAdmin-related functions
-
-
-
-
-
-local function Buttons_Player( Name )
- return "<form method='POST'><input type='hidden' name='PlayerName' value='"..Name.."'><input type='submit' name='PlayerExact' value='Exact'><input type='submit' name='Player3x3' value='3x3'></form>"
-end
-
-
-
-
-
-local function Button_World( Name )
- return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
-end
-
-
-
-
-
-local function SaveSettings()
- local SettingsIni = cIniFile()
- SettingsIni:SetValueI("Area data", "StartX", AreaStartX)
- SettingsIni:SetValueI("Area data", "StartZ", AreaStartZ)
- SettingsIni:SetValueI("Area data", "EndX", AreaEndX)
- SettingsIni:SetValueI("Area data", "EndZ", AreaEndZ)
- SettingsIni:SetValueI("Radial data", "RadialX", RadialX)
- SettingsIni:SetValueI("Radial data", "RadialZ", RadialZ)
- SettingsIni:SetValueI("Radial data", "Radius", Radius)
- SettingsIni:WriteFile("ChunkWorx.ini")
-end
-
-
-
-
-
-function HandleRequest_Generation( Request )
- local Content = ""
- if (Request.PostParams["AGHRRRR"] ~= nil) then
- GENERATION_STATE = 0
- WW_instance:QueueSaveAllChunks()
- WW_instance:QueueUnloadUnusedChunks()
- LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin")
- end
- --Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
- -- PROCESSING
- --------------------------------------------------------------------------------------------------
- local function ProcessingContent()
- local _small_content = ""
- _small_content = _small_content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
- _small_content = _small_content .. "<h4>World for operations:</h4>"..WORK_WORLD
- if (OPERATION_CODE == 0) then
- _small_content = _small_content .. "<h4>Operation:</h4>Generation"
- elseif (OPERATION_CODE == 1) then
- _small_content = _small_content .. "<h4>Operation:</h4>Regeneration"
- end
- _small_content = _small_content .. "<h4>Area: </h4>["..AreaStartX..":"..AreaStartZ.."] ["..AreaEndX..":"..AreaEndZ.."]"
- _small_content = _small_content .. "<h4>Progress:</h4>"..CURRENT.."/"..TOTAL
- _small_content = _small_content .. "<br>"
- _small_content = _small_content .. "<form method='POST'>"
- _small_content = _small_content .. "<input type='submit' name='AGHRRRR' value='Stop'>"
- _small_content = _small_content .. "</form>"
- return _small_content
- end
- if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
- Content = ProcessingContent()
- return Content
- end
- -- SELECTING
- --------------------------------------------------------------------------------------------------
- if ( Request.PostParams["FormSetWorld"] ) then
- WORK_WORLD = Request.PostParams["FormWorldName"]
- WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
- end
-
- if( Request.PostParams["SelectWorld"] ~= nil
- and Request.PostParams["WorldName"] ~= nil ) then -- World is selected!
- WORK_WORLD = Request.PostParams["WorldName"]
- WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
- end
-
- if(Request.PostParams["OperationGenerate"] ~= nil) then
- OPERATION_CODE = 0
- end
- if(Request.PostParams["OperationReGenerate"] ~= nil) then
- OPERATION_CODE = 1
- end
-
- if (GENERATION_STATE == 0) then
- if( Request.PostParams["FormAreaStartX"] ~= nil
- and Request.PostParams["FormAreaStartZ"] ~= nil
- and Request.PostParams["FormAreaEndX"] ~= nil
- and Request.PostParams["FormAreaEndZ"] ~= nil ) then --(Re)Generation valid!
- -- COMMON (Re)gen
- if( Request.PostParams["StartArea"]) then
- AreaStartX = tonumber(Request.PostParams["FormAreaStartX"])
- AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
- AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
- AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
- SaveSettings();
- if (OPERATION_CODE == 0) then
- GENERATION_STATE = 1
- elseif (OPERATION_CODE == 1) then
- GENERATION_STATE = 3
- end
- Content = ProcessingContent()
- return Content
- end
- end
- if( Request.PostParams["FormRadialX"] ~= nil
- and Request.PostParams["FormRadialZ"] ~= nil
- and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
- -- COMMON (Re)gen
- if( Request.PostParams["StartRadial"]) then
- RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0
- RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0
- Radius = tonumber(Request.PostParams["FormRadius"]) or 10
- AreaStartX = RadialX - Radius
- AreaStartZ = RadialZ - Radius
- AreaEndX = RadialX + Radius
- AreaEndZ = RadialZ + Radius
- SaveSettings()
- if (OPERATION_CODE == 0) then
- GENERATION_STATE = 1
- elseif (OPERATION_CODE == 1) then
- GENERATION_STATE = 3
- end
- Content = ProcessingContent()
- return Content
- end
- end
- -- POINT REGEN!
- if( Request.PostParams["FormPointX"] ~= nil
- and Request.PostParams["FormPointZ"] ~= nil ) then --ReGeneration valid!
- -- EXACT
- if ( Request.PostParams["PointExact"] ~= nil) then
- AreaStartX = tonumber(Request.PostParams["FormPointX"])
- AreaStartZ = tonumber(Request.PostParams["FormPointZ"])
- AreaEndX = AreaStartX
- AreaEndZ = AreaStartZ
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- -- 3x3
- if ( Request.PostParams["Point3x3"] ~= nil) then
- AreaStartX = tonumber(Request.PostParams["FormPointX"]) - 1
- AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) - 1
- AreaEndX = AreaStartX + 2
- AreaEndZ = AreaStartZ + 2
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- end
-
- local GetAreaByPlayer = function(Player)
- -- Player is valid only within this function, it cannot be stord and used later!
- AreaStartX = Player:GetChunkX()
- AreaStartZ = Player:GetChunkZ()
- end
- -- PLAYERS REGEN!
- if( Request.PostParams["PlayerExact"] ~= nil
- and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
- cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
- AreaEndX = AreaStartX
- AreaEndZ = AreaStartZ
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- if( Request.PostParams["Player3x3"] ~= nil
- and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
- cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
- AreaStartX = AreaStartX - 1
- AreaStartZ = AreaStartZ - 1
- AreaEndX = AreaStartX + 2
- AreaEndZ = AreaStartZ + 2
- GENERATION_STATE = 3
- Content = ProcessingContent()
- return Content
- end
- end
-
- --Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
- --Content = Content .. "<form method='POST'>"
- --Content = Content .. "<input type='text' name='FormWorldName' value='Input world name here'><input type='submit' name='FormSetWorld' value='Set world'>"
- --Content = Content .. "</form>"
-
- -- SELECTING WORK_WORLD
- Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
- Content = Content .. "<table>"
- local WorldNum = 0
- local AddWorldToTable = function(World)
- WorldNum = WorldNum + 1
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>"
- Content = Content .. "<td>" .. World:GetName() .. "</td>"
- Content = Content .. "<td>" .. Button_World(World:GetName()) .. "</td>"
- Content = Content .. "</tr>"
- end
- cRoot:Get():ForEachWorld(AddWorldToTable)
- if( WorldNum == 0 ) then
- Content = Content .. "<tr><td>No worlds! O_O</td></tr>"
- end
- Content = Content .. "</table>"
- Content = Content .. "<br>"
-
- -- SELECTING OPERATION
- if (OPERATION_CODE == 0) then
- Content = Content .. "<h4>Operation: Generation</h4>"
- elseif (OPERATION_CODE == 1) then
- Content = Content .. "<h4>Operation: Regeneration</h4>"
- end
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='submit' name='OperationGenerate' value='Generation'>"
- Content = Content .. "<input type='submit' name='OperationReGenerate' value='Regeneration'>"
- Content = Content .. "</form>"
-
- -- SELECTING AREA
- Content = Content .. "<h4>Area: </h4>Start X, Start Z; End X, End Z"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='text' name='FormAreaStartX' value='" .. AreaStartX .. "'><input type='text' name='FormAreaStartZ' value='" .. AreaStartZ .. "'>"
- Content = Content .. "<input type='text' name='FormAreaEndX' value='" .. AreaEndX .. "'><input type='text' name='FormAreaEndZ' value='" .. AreaEndZ .. "'>"
- Content = Content .. "<input type='submit' name='StartArea' value='Start'>"
- Content = Content .. "</form>"
-
- -- SELECTING RADIAL
- Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Radius"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='text' name='FormRadialX' value='" .. RadialX .. "'><input type='text' name='FormRadialZ' value='" .. RadialZ .. "'><input type='text' name='FormRadius' value='" .. Radius .. "'>"
- Content = Content .. "<input type='submit' name='StartRadial' value='Start'>"
- Content = Content .. "</form>"
- Content = Content .. "<br>"
- Content = Content .. "<br>"
- Content = Content .. "<br>"
-
- -- SELECTING POINT
- Content = Content .. "<h4>Point regeneration:</h4> X, Z"
- Content = Content .. "<form method='POST'>"
- Content = Content .. "<input type='text' name='FormPointX' value='0'><input type='text' name='FormPointZ' value='0'>"
- Content = Content .. "<input type='submit' name='PointExact' value='Exact'>"
- Content = Content .. "<input type='submit' name='Point3x3' value='3x3'>"
- Content = Content .. "</form>"
-
- -- SELECTING PLAYERS
- Content = Content .. "<h4>Player-based regeneration:</h4>"
- Content = Content .. "<table>"
- local PlayerNum = 0
- local AddPlayerToTable = function( Player )
- PlayerNum = PlayerNum + 1
- Content = Content .. "<tr>"
- Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
- Content = Content .. "<td>" .. Player:GetName() .. "</td>"
- Content = Content .. "<td>" .. Buttons_Player(Player:GetName()) .. "</td>"
- Content = Content .. "</tr>"
- end
- if (cRoot:Get():GetWorld(WORK_WORLD) == nil) then
- Content = Content .. "<tr><td>Incorrect world selection</td></tr>"
- else
- cRoot:Get():GetWorld(WORK_WORLD):ForEachPlayer( AddPlayerToTable )
- if( PlayerNum == 0 ) then
- Content = Content .. "<tr><td>No connected players</td></tr>"
- end
- end
- Content = Content .. "</table>"
- Content = Content .. "<br>"
- return Content
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Handy b/MCServer/Plugins/Handy
new file mode 160000
+Subproject e64a04be39ac7790abcb09de3d4c7d8fc2a2a1e
diff --git a/MCServer/Plugins/Handy/handy.lua b/MCServer/Plugins/Handy/handy.lua
deleted file mode 100644
index e4e9d3f5f..000000000
--- a/MCServer/Plugins/Handy/handy.lua
+++ /dev/null
@@ -1,28 +0,0 @@
--- Global variables
-PLUGIN = {} -- Reference to own plugin object
-CHEST_WIDTH = 9
-HANDY_VERSION = 2
---[[
-
-Handy is a plugin for other plugins. It contain no commands, no hooks, but functions to ease plugins developers' life.
-
-API:
-
-
-TODO:
-1. GetChestSlot wrapper, so it will detect double chest neighbour chest and will be able to access it.
-]]
-
-function Initialize(Plugin)
- PLUGIN = Plugin
- PLUGIN:SetName("Handy")
- PLUGIN:SetVersion(HANDY_VERSION)
-
- PluginManager = cRoot:Get():GetPluginManager()
- LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
- return true
-end
-
-function OnDisable()
- LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Handy/handy_functions.lua b/MCServer/Plugins/Handy/handy_functions.lua
deleted file mode 100644
index af43f663a..000000000
--- a/MCServer/Plugins/Handy/handy_functions.lua
+++ /dev/null
@@ -1,216 +0,0 @@
---[[
-General stuff
-]]
--- Returns Handy plugin version number
-function GetHandyVersion()
- return HANDY_VERSION
-end
--- Checks if handy is in proper version
-function CheckForRequiredVersion( inVersion )
- if( inVersion > HANDY_VERSION ) then return false end
- return true
-end
---[[
-MCS-specific _functions and nasty hacks :D
-]]
-function GetChestHeightCheat( inChest )
- local chestGrid = inChest:GetContents()
- LOGINFO( "This function serves no purpose now! You should consider chest:GetContents():GetHeight() now!" )
- LOGINFO( "Also, you might find Handy's new 'IsChestDouble()' useful for your case" )
- return chestGrid:GetHeight()
-end
-function IsChestDouble( inChest )
- local chestHeight = inChest:GetContents():GetHeight()
- if( chestHeight == 3 ) then
- return false
- end
- return true
-end
--- Those two checks how many items of given inItemID chest and player have, and how much they could fit inside them
-function ReadChestForItem( inChest, inItemID )
- return ReadGridForItems( inChest:GetContents(), inItemID )
-end
-function ReadPlayerForItem( inPlayer, inItemID )
- local inventoryFound, inventoryFree = ReadGridForItems( inPlayer:GetInventory():GetInventoryGrid(), inItemID )
- local hotbarFound, hotbarFree = ReadGridForItems( inPlayer:GetInventory():GetHotbarGrid(), inItemID )
- local itemsFound = inventoryFound + hotbarFound
- local freeSpace = inventoryFree + hotbarFree
- return itemsFound, freeSpace
-end
--- Following functions are for chest-related operations
--- BEWARE! Those assume you did checked if chest has items/space in it!
-function ReadGridForItems( inGrid, inItemID )
- local itemsFound = 0
- local freeSpace = 0
- local slotsCount = inGrid:GetNumSlots()
- local testerItem = cItem( inItemID )
- local maxStackSize = testerItem:GetMaxStackSize()
- for index = 0, (slotsCount - 1) do
- slotItem = inGrid:GetSlot( index )
- if( slotItem:IsEmpty() ) then
- freeSpace = freeSpace + maxStackSize
- else
- if( slotItem:IsStackableWith( testerItem ) ) then
- itemsFound = itemsFound + slotItem.m_ItemCount
- freeSpace = maxStackSize - slotItem.m_ItemCount
- end
- end
- end
- return itemsFound, freeSpace
-end
-
-function TakeItemsFromGrid( inGrid, inItem )
- local slotsCount = inGrid:GetNumSlots()
- local removedItem = cItem( inItem )
- for index = 0, (slotsCount - 1) do
- slotItem = inGrid:GetSlot( index )
- if( slotItem:IsSameType( removedItem ) ) then
- if( slotItem.m_ItemCount <= removedItem.m_ItemCount ) then
- removedItem.m_ItemCount = removedItem.m_ItemCount - slotItem.m_ItemCount
- inGrid:EmptySlot( index )
- else
- removedItem.m_ItemCount = slotItem.m_ItemCount - removedItem.m_ItemCount
- inGrid:SetSlot( index, removedItem )
- removedItem.m_ItemCount = 0
- end
- if( removedItem.m_ItemCount <= 0 ) then break end
- end
- end
- return removedItem.m_ItemCount
-end
---------------
-function TakeItemsFromChest( inChest, inItemID, inAmount ) -- MIGHT BE UNSAFE! CHECK FOR ITEMS FIRST!!
- local chestGrid = inChest:GetContents()
- local removedItem = cItem( inItemID, inAmount )
- TakeItemsFromGrid( chestGrid, removedItem )
-end
-function PutItemsToChest( inChest, inItemID, inAmount )
- local chestGrid = inChest:GetContents()
- local addedItem = cItem( inItemID, inAmount )
- chestGrid:AddItem( addedItem )
-end
--- Similar to chest-related.
-function TakeItemsFromPlayer( inPlayer, inItemID, inAmount ) -- MIGHT BE UNSAFE! CHECK FIRST!
- local removedItem = cItem( inItemID, inAmount )
- local inventoryGrid = inPlayer:GetInventory():GetInventoryGrid()
- local hotbarGrid = inPlayer:GetInventory():GetHotbarGrid()
- local itemsLeft = TakeItemsFromGrid( inventoryGrid, removedItem )
- if( itemsLeft > 0 ) then
- removedItem = cItem( inItemID, itemsLeft )
- TakeItemsFromGrid( hotbarGrid, removedItem )
- end
-end
-function GiveItemsToPlayer( inPlayer, inItemID, inAmount )
- local addedItem = cItem( inItemID, inAmount )
- local inventoryGrid = inPlayer:GetInventory():GetInventoryGrid()
- local hotbarGrid = inPlayer:GetInventory():GetHotbarGrid()
- local itemsAdded = inventoryGrid:AddItem( addedItem )
- if( itemsAdded < inAmount ) then
- addedItem.m_ItemCount = addedItem.m_ItemCount - itemsAdded
- hotbarGrid:AddItem( addedItem )
- end
-end
--- This function returns item max stack for a given itemID. It uses vanilla max stack size, and uses several non-common items notations;
--- Those are:
--- oneonerecord( because aparently 11record wasn't the best idea in lua scripting application )
--- carrotonastick( because it wasn't added to items.txt yet )
--- waitrecord( for same reason )
--- Feel free to ignore the difference, or to add those to items.txt
-function GetItemMaxStack( inItemID )
- local testerItem = cItem( inItemID )
- LOGINFO( "This function serves no real purpose now, maybe consider using cItem:GetMaxStackSize()?" )
- return testerItem:GetMaxStackSize()
-end
-function ItemIsArmor( inItemID, inCheckForHorseArmor )
- inCheckForHorseArmor = inCheckForHorseArmor or false
- if( inItemID == E_ITEM_LEATHER_CAP ) then return true end
- if( inItemID == E_ITEM_LEATHER_TUNIC ) then return true end
- if( inItemID == E_ITEM_LEATHER_PANTS ) then return true end
- if( inItemID == E_ITEM_LEATHER_BOOTS ) then return true end
-
- if( inItemID == E_ITEM_CHAIN_HELMET ) then return true end
- if( inItemID == E_ITEM_CHAIN_CHESTPLATE ) then return true end
- if( inItemID == E_ITEM_CHAIN_LEGGINGS ) then return true end
- if( inItemID == E_ITEM_CHAIN_BOOTS ) then return true end
-
- if( inItemID == E_ITEM_IRON_HELMET ) then return true end
- if( inItemID == E_ITEM_IRON_CHESTPLATE ) then return true end
- if( inItemID == E_ITEM_IRON_LEGGINGS ) then return true end
- if( inItemID == E_ITEM_IRON_BOOTS ) then return true end
-
- if( inItemID == E_ITEM_DIAMOND_HELMET ) then return true end
- if( inItemID == E_ITEM_DIAMOND_CHESTPLATE ) then return true end
- if( inItemID == E_ITEM_DIAMOND_LEGGINGS ) then return true end
- if( inItemID == E_ITEM_DIAMOND_BOOTS ) then return true end
-
- if( inItemID == E_ITEM_GOLD_HELMET ) then return true end
- if( inItemID == E_ITEM_GOLD_CHESTPLATE ) then return true end
- if( inItemID == E_ITEM_GOLD_LEGGINGS ) then return true end
- if( inItemID == E_ITEM_GOLD_BOOTS ) then return true end
-
- if( inCheckForHorseArmor ) then
- if( inItemID == E_ITEM_IRON_HORSE_ARMOR ) then return true end
- if( inItemID == E_ITEM_GOLD_HORSE_ARMOR ) then return true end
- if( inItemID == E_ITEM_DIAMOND_HORSE_ARMOR ) then return true end
- end
- return false
-end
--- Returns full-length playername for a short name( usefull for parsing commands )
-function GetExactPlayername( inPlayerName )
- local _result = inPlayerName
- local function SetProcessingPlayername( inPlayer )
- _result = inPlayer:GetName()
- end
- cRoot:Get():FindAndDoWithPlayer( inPlayerName, SetProcessingPlayername )
- return _result
-end
-function GetPlayerByName( inPlayerName )
- local _player
- local PlayerSetter = function( Player )
- _player = Player
- end
- cRoot:Get():FindAndDoWithPlayer( inPlayerName, PlayerSetter )
- return _player
-end
---[[
-Not-so-usual math _functions
-]]
--- Rounds floating point number. Because lua guys think this function doesn't deserve to be presented in lua's math
-function round( inX )
- if( inX%2 ~= 0.5 ) then
- return math.floor( inX + 0.5 )
- end
- return inX - 0.5
-end
---[[
-Functions I use for filework and stringswork
-]]
-function PluralString( inValue, inSingularString, inPluralString )
- local _value_string = tostring( inValue )
- if( _value_string[#_value_string] == "1" ) then
- return inSingularString
- end
- return inPluralString
-end
-function PluralItemName( inItemID, inAmount ) -- BEWARE! TEMPORAL SOLUTION THERE! :D
- local _value_string = tostring( inValue )
- local _name = ""
- if( _value_string[#_value_string] == "1" ) then
- -- singular names
- _name = ItemTypeToString( inItemID )
- else
- -- plural names
- _name = ItemTypeToString( inItemID ).."s"
- end
- return _name
-end
--- for filewriting purposes. 0 = false, 1 = true
-function StringToBool( inValue )
- if( inValue == "1" ) then return true end
- return false
-end
--- same, but reversal
-function BoolToString( inValue )
- if( inValue == true ) then return 1 end
- return 0
-end
diff --git a/MCServer/Plugins/MagicCarpet b/MCServer/Plugins/MagicCarpet
new file mode 160000
+Subproject 493f2dfa6d39f134e37c4c614cf8d6ffd10c825
diff --git a/MCServer/Plugins/MagicCarpet/objects.lua b/MCServer/Plugins/MagicCarpet/objects.lua
deleted file mode 100644
index 8d81623a5..000000000
--- a/MCServer/Plugins/MagicCarpet/objects.lua
+++ /dev/null
@@ -1,97 +0,0 @@
--- Location object
-cLocation = {}
-function cLocation:new( x, y, z )
- local object = { x = x, y = y, z = z }
- setmetatable(object, { __index = cLocation })
- return object
-end
-
--- Offsets
-cFibers = { }
-function cFibers:new()
- local object = {
- cLocation:new( 2, -1, 2 ),
- cLocation:new( 2, -1, 1 ),
- cLocation:new( 2, -1, 0 ),
- cLocation:new( 2, -1, -1 ),
- cLocation:new( 2, -1, -2 ),
- cLocation:new( 1, -1, 2 ),
- cLocation:new( 1, -1, 1 ),
- cLocation:new( 1, -1, 0 ),
- cLocation:new( 1, -1, -1 ),
- cLocation:new( 1, -1, -2 ),
- cLocation:new( 0, -1, 2 ),
- cLocation:new( 0, -1, 1 ),
- cLocation:new( 0, -1, 0 ),
- cLocation:new( 0, -1, -1 ),
- cLocation:new( 0, -1, -2 ),
- cLocation:new( -1, -1, 2 ),
- cLocation:new( -1, -1, 1 ),
- cLocation:new( -1, -1, 0 ),
- cLocation:new( -1, -1, -1 ),
- cLocation:new( -1, -1, -2 ),
- cLocation:new( -2, -1, 2 ),
- cLocation:new( -2, -1, 1 ),
- cLocation:new( -2, -1, 0 ),
- cLocation:new( -2, -1, -1 ),
- cLocation:new( -2, -1, -2 ),
- imadeit = false,
- }
- setmetatable(object, { __index = cFibers })
- return object;
-end
-
--- Carpet object
-cCarpet = {}
-function cCarpet:new()
- local object = { Location = cLocation:new(0,0,0),
- Fibers = cFibers:new(),
- }
- setmetatable(object, { __index = cCarpet })
- return object
-end
-
-function cCarpet:remove()
- local World = cRoot:Get():GetDefaultWorld()
- for i, fib in ipairs( self.Fibers ) do
- local x = self.Location.x + fib.x
- local y = self.Location.y + fib.y
- local z = self.Location.z + fib.z
- local BlockID = World:GetBlock( x, y, z )
- if( fib.imadeit == true and BlockID == E_BLOCK_GLASS ) then
- World:SetBlock( x, y, z, 0, 0 )
- fib.imadeit = false
- end
- end
-end
-
-function cCarpet:draw()
- local World = cRoot:Get():GetDefaultWorld()
- for i, fib in ipairs( self.Fibers ) do
- local x = self.Location.x + fib.x
- local y = self.Location.y + fib.y
- local z = self.Location.z + fib.z
- local BlockID = World:GetBlock( x, y, z )
- if( BlockID == 0 ) then
- fib.imadeit = true
- World:SetBlock( x, y, z, E_BLOCK_GLASS, 0 )
- else
- fib.imadeit = false
- end
- end
-end
-
-function cCarpet:moveTo( NewPos )
- local x = math.floor( NewPos.x )
- local y = math.floor( NewPos.y )
- local z = math.floor( NewPos.z )
- if( self.Location.x ~= x or self.Location.y ~= y or self.Location.z ~= z ) then
- self:remove()
- self.Location = cLocation:new( x, y, z )
- self:draw()
- end
-end
-
-function cCarpet:getY()
- return self.Location.y
-end \ No newline at end of file
diff --git a/MCServer/Plugins/MagicCarpet/plugin.lua b/MCServer/Plugins/MagicCarpet/plugin.lua
deleted file mode 100644
index 417ea0e02..000000000
--- a/MCServer/Plugins/MagicCarpet/plugin.lua
+++ /dev/null
@@ -1,81 +0,0 @@
-local Carpets = {}
-local PLUGIN
-
-function Initialize( Plugin )
- Plugin:SetName( "MagicCarpet" )
- Plugin:SetVersion( 2 )
-
- cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)
- cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_DESTROYED, OnDisconnect)
-
- local PluginManager = cPluginManager:Get()
- PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
-
- PLUGIN = Plugin
-
- LOG( "Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
- return true
-end
-
-
-
-
-
-function OnDisable()
- LOG( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
- for i, Carpet in pairs( Carpets ) do
- Carpet:remove()
- end
-end
-
-
-
-
-
-function HandleCarpetCommand( Split, Player )
- Carpet = Carpets[ Player ]
-
- if( Carpet == nil ) then
- Carpets[ Player ] = cCarpet:new()
- Player:SendMessageSuccess("You're on a magic carpet!")
- Player:SendMessageInfo("Look straight down to descend. Jump to ascend.")
- else
- Carpet:remove()
- Carpets[ Player ] = nil
- Player:SendMessageSuccess("The carpet vanished!")
- end
-
- return true
-end
-
-
-
-
-
-function OnDisconnect( Reason, Player )
- local Carpet = Carpets[ Player ]
- if( Carpet ~= nil ) then
- Carpet:remove()
- end
- Carpets[ Player ] = nil
-end
-
-
-
-
-
-function OnPlayerMoving(Player)
- local Carpet = Carpets[ Player ]
- if( Carpet == nil ) then
- return
- end
-
- if( Player:GetPitch() == 90 ) then
- Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) )
- else
- if( Player:GetPosY() < Carpet:getY() ) then
- Player:TeleportToCoords(Player:GetPosX(), Carpet:getY() + 0.2, Player:GetPosZ())
- end
- Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
- end
-end