commit
843605d59e
20
.gitignore
vendored
20
.gitignore
vendored
@ -12,3 +12,23 @@ cloc.xsl
|
||||
*.suo
|
||||
/EveryNight.cmd
|
||||
*.sublime-*
|
||||
|
||||
# emacs stuff
|
||||
*.*~
|
||||
|
||||
# world inside source
|
||||
ChunkWorx.ini
|
||||
groups.ini
|
||||
items.ini
|
||||
monsters.ini
|
||||
settings.ini
|
||||
terrain.ini
|
||||
users.ini
|
||||
webadmin.ini
|
||||
world.ini
|
||||
crafting.txt
|
||||
motd.txt
|
||||
logs
|
||||
players
|
||||
world
|
||||
world_nether
|
||||
|
@ -12,5 +12,6 @@ rs2k
|
||||
Duralex
|
||||
mtilden
|
||||
Luksor
|
||||
marmot
|
||||
|
||||
Please add yourself to this list if you contribute to MCServer.
|
||||
|
92
GNUmakefile
92
GNUmakefile
@ -46,9 +46,11 @@ ifeq ($(release),1)
|
||||
################
|
||||
# release build - fastest run-time, no gdb support
|
||||
################
|
||||
CC_OPTIONS = -s -g -O3 -DNDEBUG
|
||||
CXX_OPTIONS = -s -g -O3 -DNDEBUG
|
||||
|
||||
CC_OPTIONS = -O3 -DNDEBUG -DLUA_USE_DLOPEN
|
||||
CXX_OPTIONS = -O3 -DNDEBUG -DLUA_USE_DLOPEN
|
||||
LNK_OPTIONS = -pthread -O3
|
||||
|
||||
BUILDDIR = build/release/
|
||||
|
||||
else
|
||||
@ -56,42 +58,39 @@ ifeq ($(profile),1)
|
||||
################
|
||||
# profile build - a release build with symbols and profiling engine built in
|
||||
################
|
||||
CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
||||
CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
||||
LNK_OPTIONS = -pthread -ggdb -O3 -pg
|
||||
BUILDDIR = build/profile/
|
||||
|
||||
else
|
||||
ifeq ($(pedantic),1)
|
||||
################
|
||||
# pedantic build - basically a debug build with lots of warnings
|
||||
################
|
||||
CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
||||
CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
||||
LNK_OPTIONS = -pthread -ggdb
|
||||
BUILDDIR = build/pedantic/
|
||||
CC_OPTIONS = -g -ggdb -O3 -pg -DNDEBUG -DLUA_USE_DLOPEN
|
||||
CXX_OPTIONS = -g -ggdb -O3 -pg -DNDEBUG -DLUA_USE_DLOPEN
|
||||
LNK_OPTIONS = -pthread -ggdb -O3 -pg
|
||||
|
||||
BUILDDIR = build/profile/
|
||||
|
||||
else
|
||||
################
|
||||
# debug build - fully traceable by gdb in C++ code, slowest
|
||||
# Since C code is used only for supporting libraries (zlib, lua), it is still O3-optimized
|
||||
# Since C code is used only for supporting libraries (zlib, lua), it is still Ofast-optimized
|
||||
################
|
||||
CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
|
||||
CXX_OPTIONS = -s -ggdb -g -D_DEBUG
|
||||
LNK_OPTIONS = -pthread -g -ggdb
|
||||
|
||||
CC_OPTIONS = -ggdb -g -D_DEBUG -O3 -DLUA_USE_DLOPEN
|
||||
CXX_OPTIONS = -ggdb -g -D_DEBUG -O1 -DLUA_USE_DLOPEN
|
||||
LNK_OPTIONS = -pthread -g -ggdb -O1
|
||||
|
||||
BUILDDIR = build/debug/
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
##################################################
|
||||
# Always be warning.
|
||||
|
||||
CXX_OPTIONS += -Wall
|
||||
|
||||
###################################################
|
||||
# Fix Crypto++ warnings in clang
|
||||
|
||||
ifeq ($(shell $(CXX) --version 2>&1 | grep -i -c "clang version"),0)
|
||||
CC_OPTIONS += -Wno-tautological-compare
|
||||
CXX_OPTIONS += -Wno-tautological-compare
|
||||
disableasm = 1
|
||||
ifeq ($(shell $(CXX) --version 2>&1 | grep -i -c "clang version"),1)
|
||||
CC_OPTIONS += -DCRYPTOPP_DISABLE_ASM
|
||||
CXX_OPTIONS += -DCRYPTOPP_DISABLE_ASM
|
||||
endif
|
||||
|
||||
|
||||
@ -103,7 +102,7 @@ endif
|
||||
|
||||
UNAME := $(shell uname -s)
|
||||
ifeq ($(UNAME),Linux)
|
||||
LNK_LIBS = -lstdc++ -ldl
|
||||
LNK_LIBS = -lstdc++ -ldl -lm
|
||||
else
|
||||
LNK_LIBS = -lstdc++ -lltdl
|
||||
endif
|
||||
@ -112,6 +111,14 @@ endif
|
||||
|
||||
|
||||
|
||||
###################################################
|
||||
# Export all symbols from the executable, so that LuaRocks may bind to Lua routines:
|
||||
LNK_OPTIONS += -rdynamic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###################################################
|
||||
# 32-bit build override in 64-bit build environments
|
||||
|
||||
@ -126,36 +133,12 @@ endif
|
||||
|
||||
|
||||
|
||||
###################################################
|
||||
# Clang doesn't seem to support CryptoPP's assembly mode, disable it for now (CryptoPP 5.6.2)
|
||||
|
||||
ifeq ($(disableasm),1)
|
||||
CC_OPTIONS += -DCRYPTOPP_DISABLE_ASM
|
||||
CXX_OPTIONS += -DCRYPTOPP_DISABLE_ASM
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###################################################
|
||||
# INCLUDE directories for MCServer
|
||||
#
|
||||
|
||||
INCLUDE = -I.\
|
||||
-Isource\
|
||||
-Isource/md5\
|
||||
-IWebServer\
|
||||
-Isource/items\
|
||||
-Isource/blocks\
|
||||
-Itolua++-1.0.93/src/lib\
|
||||
-Ilua-5.1.4/src\
|
||||
-Izlib-1.2.7\
|
||||
-IiniFile\
|
||||
-Itolua++-1.0.93/include\
|
||||
-Ijsoncpp-src-0.5.0/include\
|
||||
-Ijsoncpp-src-0.5.0/src/lib_json\
|
||||
-Iexpat
|
||||
INCLUDE = -Isrc\
|
||||
-Ilib\
|
||||
-Ilib/jsoncpp/include
|
||||
|
||||
|
||||
|
||||
@ -163,11 +146,8 @@ INCLUDE = -I.\
|
||||
|
||||
###################################################
|
||||
# Build MCServer
|
||||
#
|
||||
|
||||
# 2012_11_08 _X: Removed: squirrel_3_0_1_stable
|
||||
|
||||
SOURCES := $(shell find CryptoPP lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source tolua++-1.0.93 iniFile WebServer expat '(' -name '*.cpp' -o -name '*.c' ')')
|
||||
SOURCES := $(shell find src lib '(' -name '*.cpp' -o -name '*.c' ')')
|
||||
SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES))
|
||||
OBJECTS := $(patsubst %.c,$(BUILDDIR)%.o,$(SOURCES))
|
||||
OBJECTS := $(patsubst %.cpp,$(BUILDDIR)%.o,$(OBJECTS))
|
||||
|
@ -1,4 +1,5 @@
|
||||
..\MCServer\MCServer.exe
|
||||
..\MCServer\*.dll
|
||||
..\MCServer\Plugins
|
||||
..\MCServer\webadmin
|
||||
..\MCServer\crafting.txt
|
||||
@ -11,5 +12,3 @@ Lua-LICENSE.txt
|
||||
LuaExpat-license.html
|
||||
LuaSQLite3-LICENSE.txt
|
||||
MersenneTwister-LICENSE.txt
|
||||
settings.example.ini
|
||||
webadmin.example.ini
|
@ -5,4 +5,4 @@ VC2008\Release\Lua\*.pdb
|
||||
VC2008\Release\ToLua\*.pdb
|
||||
VC2008\Release\webserver\*.pdb
|
||||
VC2008\Release\zlib\*.pdb
|
||||
source\Bindings.*
|
||||
src\Bindings.*
|
10
MCServer/.gitignore
vendored
10
MCServer/.gitignore
vendored
@ -1,9 +1,13 @@
|
||||
*.exe
|
||||
*.dll
|
||||
*.exp
|
||||
*.lib
|
||||
*.ini
|
||||
MCServer
|
||||
logs
|
||||
players
|
||||
world*
|
||||
API/
|
||||
API.txt
|
||||
API_wiki.txt
|
||||
*.dat
|
||||
@ -13,7 +17,13 @@ schematics
|
||||
*.pdb
|
||||
memdump*
|
||||
*.grab
|
||||
Galleries.cfg
|
||||
Galleries.example.cfg
|
||||
Galleries.sqlite
|
||||
ProtectionAreas.sqlite
|
||||
helgrind.log
|
||||
valgrind.log
|
||||
motd.txt
|
||||
*.deuser
|
||||
*.dmp
|
||||
*.xml
|
||||
|
2748
MCServer/Plugins/APIDump/APIDesc.lua
Normal file
2748
MCServer/Plugins/APIDump/APIDesc.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,162 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<file>
|
||||
<filename>main.lua</filename>
|
||||
<filename>APIDesc.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Classes\BlockEntities.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnBlockToPickups.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnChat.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnChunkAvailable.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnChunkGenerated.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnChunkGenerating.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnChunkUnloaded.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnChunkUnloading.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnCollectingPickup.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnCraftingNoRecipe.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnDisconnect.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnExecuteCommand.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnExploded.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnExploding.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnHandshake.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnHopperPullingItem.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnHopperPushingItem.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnKilling.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnLogin.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerAnimation.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerBreakingBlock.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerBrokenBlock.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerEating.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerJoined.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerLeftClick.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerMoving.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerPlacedBlock.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerPlacingBlock.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerRightClick.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerRightClickingEntity.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerShooting.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerSpawned.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerTossingItem.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerUsedBlock.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerUsedItem.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerUsingBlock.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPlayerUsingItem.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPostCrafting.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnPreCrafting.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnSpawnedEntity.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnSpawnedMonster.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnSpawningEntity.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnSpawningMonster.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnTakeDamage.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnTick.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnUpdatedSign.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnUpdatingSign.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnWeatherChanged.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnWeatherChanging.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Hooks\OnWorldTick.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>Classes\Projectiles.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>main_APIDump.lua</filename>
|
||||
</file>
|
||||
</project>
|
||||
|
243
MCServer/Plugins/APIDump/Classes/BlockEntities.lua
Normal file
243
MCServer/Plugins/APIDump/Classes/BlockEntities.lua
Normal file
@ -0,0 +1,243 @@
|
||||
return
|
||||
{
|
||||
cBlockEntity =
|
||||
{
|
||||
Desc = [[
|
||||
Block entities are simply blocks in the world that have persistent data, such as the text for a sign
|
||||
or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in.
|
||||
The cBlockEntity class acts as a common ancestor for all the individual block entities.
|
||||
]],
|
||||
|
||||
Functions =
|
||||
{
|
||||
GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" },
|
||||
GetChunkX = { Params = "", Return = "number", Notes = "Returns the chunk X-coord of the block entity's chunk" },
|
||||
GetChunkZ = { Params = "", Return = "number", Notes = "Returns the chunk Z-coord of the block entity's chunk" },
|
||||
GetPosX = { Params = "", Return = "number", Notes = "Returns the block X-coord of the block entity's block" },
|
||||
GetPosY = { Params = "", Return = "number", Notes = "Returns the block Y-coord of the block entity's block" },
|
||||
GetPosZ = { Params = "", Return = "number", Notes = "Returns the block Z-coord of the block entity's block" },
|
||||
GetRelX = { Params = "", Return = "number", Notes = "Returns the relative X coord of the block entity's block within the chunk" },
|
||||
GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" },
|
||||
GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" },
|
||||
},
|
||||
},
|
||||
|
||||
cBlockEntityWithItems =
|
||||
{
|
||||
Desc = [[
|
||||
This class is a common ancestor for all {{cBlockEntity|block entities}} that provide item storage.
|
||||
Internally, the object has a {{cItemGrid|cItemGrid}} object for storing the items; this ItemGrid is
|
||||
accessible through the API. The storage is a grid of items, items in it can be addressed either by a slot
|
||||
number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage
|
||||
is monitored for changes and the changes are immediately sent to clients of the UI window.
|
||||
]],
|
||||
|
||||
Inherits = "cBlockEntity",
|
||||
|
||||
Functions =
|
||||
{
|
||||
GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" },
|
||||
GetSlot =
|
||||
{
|
||||
{ Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" },
|
||||
{ Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" },
|
||||
},
|
||||
SetSlot =
|
||||
{
|
||||
{ Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" },
|
||||
{ Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
cChestEntity =
|
||||
{
|
||||
Desc = [[
|
||||
A chest entity is a {{cBlockEntityWithItems|cBlockEntityWithItems}} descendant that represents a chest
|
||||
in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate
|
||||
in any way.</p>
|
||||
<p>
|
||||
To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with
|
||||
either DoWithChestAt() or ForEachChestInChunk() function. See the code example below
|
||||
]],
|
||||
|
||||
Inherits = "cBlockEntityWithItems",
|
||||
|
||||
Constants =
|
||||
{
|
||||
ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" },
|
||||
ContentsWidth = { Notes = "Width of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" },
|
||||
},
|
||||
AdditionalInfo =
|
||||
{
|
||||
{
|
||||
Header = "Code example",
|
||||
Contents = [[
|
||||
The following example code sets the top-left item of each chest in the same chunk as Player to
|
||||
64 * diamond:
|
||||
<pre class="prettyprint lang-lua">
|
||||
-- Player is a {{cPlayer}} object instance
|
||||
local World = Player:GetWorld();
|
||||
World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
|
||||
function (ChestEntity)
|
||||
ChestEntity:SetSlot(0, 0, cItem(E_ITEM_DIAMOND, 64));
|
||||
end
|
||||
);
|
||||
</pre>
|
||||
]],
|
||||
},
|
||||
}, -- AdditionalInfo
|
||||
},
|
||||
|
||||
cDispenserEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents a dispenser block entity in the world. Most of this block entity's
|
||||
functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents
|
||||
the behavior common with a {{cDropperEntity|dropper}} entity.
|
||||
]],
|
||||
Inherits = "cDropSpenserEntity",
|
||||
},
|
||||
|
||||
cDropperEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents a dropper block entity in the world. Most of this block entity's functionality
|
||||
is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior
|
||||
common with the {{cDispenserEntity|dispenser}} entity.</p>
|
||||
<p>
|
||||
An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks).
|
||||
]],
|
||||
Inherits = "cDropSpenserEntity",
|
||||
}, -- cDropperEntity
|
||||
|
||||
cDropSpenserEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" },
|
||||
AddDropSpenserDir = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "BlockX, BlockY, BlockZ", Notes = "Adjusts the block coords to where the dropspenser items materialize" },
|
||||
SetRedstonePower = { Params = "IsPowered", Return = "", Notes = "Sets the redstone status of the dropspenser. If the redstone power goes from off to on, the dropspenser will be activated" },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" },
|
||||
ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" },
|
||||
},
|
||||
Inherits = "cBlockEntityWithItems";
|
||||
}, -- cDropSpenserEntity
|
||||
|
||||
cFurnaceEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents a furnace block entity in the world.</p>
|
||||
<p>
|
||||
See also {{cRoot}}'s GetFurnaceRecipe() and GetFurnaceFuelBurnTime() functions
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" },
|
||||
GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" },
|
||||
GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" },
|
||||
GetInputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the input slot" },
|
||||
GetOutputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the output slot" },
|
||||
GetTimeCooked = { Params = "", Return = "number", Notes = "Returns the time that the current item has been cooking, in ticks" },
|
||||
HasFuelTimeLeft = { Params = "", Return = "bool", Notes = "Returns true if there's time before the current fuel is depleted" },
|
||||
SetFuelSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the fuel slot" },
|
||||
SetInputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the input slot" },
|
||||
SetOutputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the output slot" },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
fsInput = { Notes = "Index of the input slot" },
|
||||
fsFuel = { Notes = "Index of the fuel slot" },
|
||||
fsOutput = { Notes = "Index of the output slot" },
|
||||
ContentsWidth = { Notes = "Width (X) of the {{cItemGrid|cItemGrid}} representing the contents" },
|
||||
ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid|cItemGrid}} representing the contents" },
|
||||
},
|
||||
ConstantGroups =
|
||||
{
|
||||
SlotIndices =
|
||||
{
|
||||
Include = "fs.*",
|
||||
TextBefore = "When using the GetSlot() or SetSlot() function, use these constants for slot index:",
|
||||
},
|
||||
},
|
||||
Inherits = "cBlockEntityWithItems"
|
||||
}, -- cFurnaceEntity
|
||||
|
||||
cHopperEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents a hopper block entity in the world.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
ContentsHeight = { Notes = "Height (Y) of the internal {{cItemGrid}} representing the hopper contents." },
|
||||
ContentsWidth = { Notes = "Width (X) of the internal {{cItemGrid}} representing the hopper contents." },
|
||||
TICKS_PER_TRANSFER = { Notes = "Number of ticks between when the hopper transfers items." },
|
||||
},
|
||||
Inherits = "cBlockEntityWithItems",
|
||||
}, -- cHopperEntity
|
||||
|
||||
cJukeboxEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents a jukebox in the world. It can play the records, either when the
|
||||
{{cPlayer|player}} uses the record on the jukebox, or when a plugin instructs it to play.
|
||||
]],
|
||||
Inherits = "cBlockEntity",
|
||||
Functions =
|
||||
{
|
||||
EjectRecord = { Params = "", Return = "", Notes = "Ejects the current record as a {{cPickup|pickup}}. No action if there's no current record. To remove record without generating the pickup, use SetRecord(0)" },
|
||||
GetRecord = { Params = "", Return = "number", Notes = "Returns the record currently present. Zero for no record, E_ITEM_*_DISC for records." },
|
||||
PlayRecord = { Params = "", Return = "", Notes = "Plays the currently present record. No action if there's no current record." },
|
||||
SetRecord = { Params = "number", Return = "", Notes = "Sets the currently present record. Use zero for no record, or E_ITEM_*_DISC for records." },
|
||||
},
|
||||
}, -- cJukeboxEntity
|
||||
|
||||
cNoteEntity =
|
||||
{
|
||||
Desc = [[
|
||||
This class represents a note block entity in the world. It takes care of the note block's pitch,
|
||||
and also can play the sound, either when the {{cPlayer|player}} right-clicks it, redstone activates
|
||||
it, or upon a plugin's request.</p>
|
||||
<p>
|
||||
The pitch is stored as an integer between 0 and 24.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
GetPitch = { Params = "", Return = "number", Notes = "Returns the current pitch set for the block" },
|
||||
IncrementPitch = { Params = "", Return = "", Notes = "Adds 1 to the current pitch. Wraps around to 0 when the pitch cannot go any higher." },
|
||||
MakeSound = { Params = "", Return = "", Notes = "Plays the sound for all {{cClientHandle|clients}} near this block." },
|
||||
SetPitch = { Params = "Pitch", Return = "", Notes = "Sets a new pitch for the block." },
|
||||
},
|
||||
Inherits = "cBlockEntity",
|
||||
}, -- cNoteEntity
|
||||
|
||||
cSignEntity =
|
||||
{
|
||||
Desc = [[
|
||||
A sign entity represents a sign in the world. This class is only used when generating chunks, so
|
||||
that the plugins may generate signs within new chunks. See the code example in {{cChunkDesc}}.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
GetLine = { Params = "LineIndex", Return = "string", Notes = "Returns the specified line. LineIndex is expected between 0 and 3. Returns empty string and logs to server console when LineIndex is invalid." },
|
||||
SetLine = { Params = "LineIndex, LineText", Return = "", Notes = "Sets the specified line. LineIndex is expected between 0 and 3. Logs to server console when LineIndex is invalid." },
|
||||
SetLines = { Params = "Line1, Line2, Line3, Line4", Return = "", Notes = "Sets all the sign's lines at once." },
|
||||
},
|
||||
Inherits = "cBlockEntity";
|
||||
}, -- cSignEntity
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
111
MCServer/Plugins/APIDump/Classes/Projectiles.lua
Normal file
111
MCServer/Plugins/APIDump/Classes/Projectiles.lua
Normal file
@ -0,0 +1,111 @@
|
||||
return
|
||||
{
|
||||
cArrowEntity =
|
||||
{
|
||||
Desc = [[
|
||||
Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" },
|
||||
GetDamageCoeff = { Params = "", Return = "number", Notes = "Returns the damage coefficient stored within the arrow. The damage dealt by this arrow is multiplied by this coeff" },
|
||||
GetPickupState = { Params = "", Return = "PickupState", Notes = "Returns the pickup state (one of the psXXX constants, above)" },
|
||||
IsCritical = { Params = "", Return = "bool", Notes = "Returns true if the arrow should deal critical damage. Based on the bow charge when the arrow was shot." },
|
||||
SetDamageCoeff = { Params = "number", Return = "", Notes = "Sets the damage coefficient. The damage dealt by this arrow is multiplied by this coeff" },
|
||||
SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" },
|
||||
SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" },
|
||||
psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" },
|
||||
psNoPickup = { Notes = "The arrow cannot be picked up at all" },
|
||||
},
|
||||
ConstantGroups =
|
||||
{
|
||||
PickupState =
|
||||
{
|
||||
Include = "ps.*",
|
||||
TextBefore = [[
|
||||
The following constants are used to signalize whether the arrow, once it lands, can be picked by
|
||||
players:
|
||||
]],
|
||||
},
|
||||
},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cArrowEntity
|
||||
|
||||
cFireChargeEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cFireChargeEntity
|
||||
|
||||
cGhastFireballEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cGhastFireballEntity
|
||||
|
||||
cProjectileEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Functions =
|
||||
{
|
||||
GetCreator = { Params = "", Return = "{{cEntity}} descendant", Notes = "Returns the entity who created this projectile. May return nil." },
|
||||
GetMCAClassName = { Params = "", Return = "string", Notes = "Returns the string that identifies the projectile type (class name) in MCA files" },
|
||||
GetProjectileKind = { Params = "", Return = "ProjectileKind", Notes = "Returns the kind of this projectile (pkXXX constant)" },
|
||||
IsInGround = { Params = "", Return = "bool", Notes = "Returns true if this projectile has hit the ground." },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" },
|
||||
pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" },
|
||||
pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" },
|
||||
pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" },
|
||||
pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" },
|
||||
pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" },
|
||||
pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" },
|
||||
pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" },
|
||||
pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" },
|
||||
pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" },
|
||||
pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" },
|
||||
},
|
||||
ConstantGroups =
|
||||
{
|
||||
ProjectileKind =
|
||||
{
|
||||
Include = "pk.*",
|
||||
TextBefore = "The following constants are used to distinguish between the different projectile kinds:",
|
||||
},
|
||||
},
|
||||
Inherits = "cEntity",
|
||||
}, -- cProjectileEntity
|
||||
|
||||
cThrownEggEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cThrownEggEntity
|
||||
|
||||
cThrownEnderPearlEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cThrownEnderPearlEntity
|
||||
|
||||
cThrownSnowballEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cThrownSnowballEntity
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
62
MCServer/Plugins/APIDump/Hooks/OnBlockToPickups.lua
Normal file
62
MCServer/Plugins/APIDump/Hooks/OnBlockToPickups.lua
Normal file
@ -0,0 +1,62 @@
|
||||
return
|
||||
{
|
||||
HOOK_BLOCK_TO_PICKUPS =
|
||||
{
|
||||
CalledWhen = "A block is about to be dug ({{cPlayer|player}}, {{cEntity|entity}} or natural reason), plugins may override what pickups that will produce.",
|
||||
DefaultFnName = "OnBlockToPickups", -- also used as pagename
|
||||
Desc = [[
|
||||
This callback gets called whenever a block is about to be dug. This includes {{cPlayer|players}}
|
||||
digging blocks, entities causing blocks to disappear ({{cTNTEntity|TNT}}, Endermen) and natural
|
||||
causes (water washing away a block). Plugins may override the amount and kinds of pickups this
|
||||
action produces.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
|
||||
{ Name = "Digger", Type = "{{cEntity}} descendant", Notes = "The entity causing the digging. May be a {{cPlayer}}, {{cTNTEntity}} or even nil (natural causes)" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "Block type of the block" },
|
||||
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "Block meta of the block" },
|
||||
{ Name = "Pickups", Type = "{{cItems}}", Notes = "Items that will be spawned as pickups" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next callback in the hook chain will be called. If
|
||||
the function returns true, no other callbacks in the chain will be called.</p>
|
||||
<p>
|
||||
Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable
|
||||
pickups, you need to Clear the object first, then return true.
|
||||
]],
|
||||
CodeExamples =
|
||||
{
|
||||
{
|
||||
Title = "Modify pickups",
|
||||
Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).",
|
||||
Code = [[
|
||||
function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups)
|
||||
if (a_Digger ~= nil) then
|
||||
-- Not a natural cause
|
||||
return false;
|
||||
end
|
||||
if (a_BlockType ~= E_BLOCK_TALL_GRASS) then
|
||||
-- Not a tall grass being washed away
|
||||
return false;
|
||||
end
|
||||
|
||||
-- Remove all pickups suggested by MCServer:
|
||||
a_Pickups:Clear();
|
||||
|
||||
-- Drop a diamond:
|
||||
a_Pickups:Add(cItem(E_ITEM_DIAMOND));
|
||||
return true;
|
||||
end;
|
||||
]],
|
||||
},
|
||||
} , -- CodeExamples
|
||||
}, -- HOOK_BLOCK_TO_PICKUPS
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
29
MCServer/Plugins/APIDump/Hooks/OnChat.lua
Normal file
29
MCServer/Plugins/APIDump/Hooks/OnChat.lua
Normal file
@ -0,0 +1,29 @@
|
||||
return
|
||||
{
|
||||
HOOK_CHAT =
|
||||
{
|
||||
CalledWhen = "Player sends a chat message",
|
||||
DefaultFnName = "OnChat", -- also used as pagename
|
||||
Desc = [[
|
||||
A plugin may implement an OnChat() function and register it as a Hook to process chat messages from
|
||||
the players. The function is then called for every in-game message sent from any player. Note that
|
||||
commands are handled separately using a command framework API.
|
||||
]],
|
||||
Params = {
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who sent the message" },
|
||||
{ Name = "Message", Type = "string", Notes = "The message" },
|
||||
},
|
||||
Returns = [[
|
||||
The plugin may return 2 values. The first is a boolean specifying whether the hook handling is to be
|
||||
stopped or not. If it is false, the message is broadcast to all players in the world. If it is true,
|
||||
no message is broadcast and no further action is taken.</p>
|
||||
<p>
|
||||
The second value is specifies the message to broadcast. This way, plugins may modify the message. If
|
||||
the second value is not provided, the original message is used.
|
||||
]],
|
||||
}, -- HOOK_CHAT
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
27
MCServer/Plugins/APIDump/Hooks/OnChunkAvailable.lua
Normal file
27
MCServer/Plugins/APIDump/Hooks/OnChunkAvailable.lua
Normal file
@ -0,0 +1,27 @@
|
||||
return
|
||||
{
|
||||
HOOK_CHUNK_AVAILABLE =
|
||||
{
|
||||
CalledWhen = "A chunk has just been added to world, either generated or loaded. ",
|
||||
DefaultFnName = "OnChunkAvailable", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a chunk is either generated or loaded from the disk. The chunk is
|
||||
already available for manipulation using the {{cWorld}} API. This is a notification-only callback,
|
||||
there is no behavior that plugins could override.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk belongs" },
|
||||
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
|
||||
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event.
|
||||
]],
|
||||
}, -- HOOK_CHUNK_AVAILABLE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
67
MCServer/Plugins/APIDump/Hooks/OnChunkGenerated.lua
Normal file
67
MCServer/Plugins/APIDump/Hooks/OnChunkGenerated.lua
Normal file
@ -0,0 +1,67 @@
|
||||
return
|
||||
{
|
||||
HOOK_CHUNK_GENERATED =
|
||||
{
|
||||
CalledWhen = "After a chunk was generated. Notification only.",
|
||||
DefaultFnName = "OnChunkGenerated", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when world generator finished its work on a chunk. The chunk data has already
|
||||
been generated and is about to be stored in the {{cWorld|world}}. A plugin may provide some
|
||||
last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the
|
||||
world, so regular {{cWorld}} block API will not work! Instead, use the {{cChunkDesc}} object
|
||||
received as the parameter.</p>
|
||||
<p>
|
||||
See also the {{OnChunkGenerating|HOOK_CHUNK_GENERATING}} hook.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" },
|
||||
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
|
||||
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
|
||||
{ Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data. Plugins may still modify the chunk data contained." },
|
||||
},
|
||||
Returns = [[
|
||||
If the plugin returns false or no value, MCServer will call other plugins' callbacks for this event.
|
||||
If a plugin returns true, no other callback is called for this event.</p>
|
||||
<p>
|
||||
In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world.
|
||||
]],
|
||||
CodeExamples =
|
||||
{
|
||||
{
|
||||
Title = "Generate emerald ore",
|
||||
Desc = "This example callback function generates one block of emerald ore in each chunk, under the condition that the randomly chosen location is in an ExtremeHills biome.",
|
||||
Code = [[
|
||||
function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
|
||||
-- Generate a psaudorandom value that is always the same for the same X/Z pair, but is otherwise random enough:
|
||||
-- This is actually similar to how MCServer does its noise functions
|
||||
local PseudoRandom = (a_ChunkX * 57 + a_ChunkZ) * 57 + 19785486
|
||||
PseudoRandom = PseudoRandom * 8192 + PseudoRandom;
|
||||
PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff;
|
||||
PseudoRandom = PseudoRandom / 7;
|
||||
|
||||
-- Based on the PseudoRandom value, choose a location for the ore:
|
||||
local OreX = PseudoRandom % 16;
|
||||
local OreY = 2 + ((PseudoRandom / 16) % 20);
|
||||
local OreZ = (PseudoRandom / 320) % 16;
|
||||
|
||||
-- Check if the location is in ExtremeHills:
|
||||
if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then
|
||||
return false;
|
||||
end
|
||||
|
||||
-- Only replace allowed blocks with the ore:
|
||||
local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ);
|
||||
if (
|
||||
(CurrBlock == E_BLOCK_STONE) or
|
||||
(CurrBlock == E_BLOCK_DIRT) or
|
||||
(CurrBlock == E_BLOCK_GRAVEL)
|
||||
) then
|
||||
a_ChunkDesc:SetBlockTypeMeta(OreX, OreY, OreZ, E_BLOCK_EMERALD_ORE, 0);
|
||||
end
|
||||
end;
|
||||
]],
|
||||
},
|
||||
} , -- CodeExamples
|
||||
}, -- HOOK_CHUNK_GENERATED
|
||||
}
|
35
MCServer/Plugins/APIDump/Hooks/OnChunkGenerating.lua
Normal file
35
MCServer/Plugins/APIDump/Hooks/OnChunkGenerating.lua
Normal file
@ -0,0 +1,35 @@
|
||||
return
|
||||
{
|
||||
HOOK_CHUNK_GENERATING =
|
||||
{
|
||||
CalledWhen = "A chunk is about to be generated. Plugin can override the built-in generator.",
|
||||
DefaultFnName = "OnChunkGenerating", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called before the world generator starts generating a chunk. The plugin may provide
|
||||
some or all parts of the generation, by-passing the built-in generator. The function is given access
|
||||
to the {{cChunkDesc|ChunkDesc}} object representing the contents of the chunk. It may override parts
|
||||
of the built-in generator by using the object's <i>SetUseDefaultXXX(false)</i> functions. After all
|
||||
the callbacks for a chunk have been processed, the server will generate the chunk based on the
|
||||
{{cChunkDesc|ChunkDesc}} description - those parts that are set for generating (by default
|
||||
everything) are generated, the rest are read from the ChunkDesc object.</p>
|
||||
<p>
|
||||
See also the {{OnChunkGenerated|HOOK_CHUNK_GENERATED}} hook.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" },
|
||||
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
|
||||
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
|
||||
{ Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data." },
|
||||
},
|
||||
Returns = [[
|
||||
If this function returns true, the server will not call any other plugin with the same chunk. If
|
||||
this function returns false, the server will call the rest of the plugins with the same chunk,
|
||||
possibly overwriting the ChunkDesc's contents.
|
||||
]],
|
||||
}, -- HOOK_CHUNK_GENERATING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
28
MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua
Normal file
28
MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua
Normal file
@ -0,0 +1,28 @@
|
||||
return
|
||||
{
|
||||
HOOK_CHUNK_UNLOADED =
|
||||
{
|
||||
CalledWhen = "A chunk has been unloaded from the memory.",
|
||||
DefaultFnName = "OnChunkUnloaded", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a chunk is unloaded from the memory. Though technically still in memory,
|
||||
the plugin should behave as if the chunk was already not present. In particular, {{cWorld}} block
|
||||
API should not be used in the area of the specified chunk.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" },
|
||||
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
|
||||
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event. There is no behavior that plugins could
|
||||
override.
|
||||
]],
|
||||
}, -- HOOK_CHUNK_UNLOADED
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
30
MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua
Normal file
30
MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua
Normal file
@ -0,0 +1,30 @@
|
||||
return
|
||||
{
|
||||
HOOK_CHUNK_UNLOADING =
|
||||
{
|
||||
CalledWhen = " A chunk is about to be unloaded from the memory. Plugins may refuse the unload.",
|
||||
DefaultFnName = "OnChunkUnloading", -- also used as pagename
|
||||
Desc = [[
|
||||
MCServer calls this function when a chunk is about to be unloaded from the memory. A plugin may
|
||||
force MCServer to keep the chunk in memory by returning true.</p>
|
||||
<p>
|
||||
FIXME: The return value should be used only for event propagation stopping, not for the actual
|
||||
decision whether to unload.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" },
|
||||
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
|
||||
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called and finally MCServer
|
||||
unloads the chunk. If the function returns true, no other callback is called for this event and the
|
||||
chunk is left in the memory.
|
||||
]],
|
||||
}, -- HOOK_CHUNK_UNLOADING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnCollectingPickup.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnCollectingPickup.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_COLLECTING_PICKUP =
|
||||
{
|
||||
CalledWhen = "Player is about to collect a pickup. Plugin can refuse / override behavior. ",
|
||||
DefaultFnName = "OnCollectingPickup", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a player is about to collect a pickup. Plugins may refuse the action.</p>
|
||||
<p>
|
||||
Pickup collection happens within the world tick, so if the collecting is refused, it will be tried
|
||||
again in the next world tick, as long as the player is within reach of the pickup.</p>
|
||||
<p>
|
||||
FIXME: There is no OnCollectedPickup() callback.</p>
|
||||
<p>
|
||||
FIXME: This callback is called even if the pickup doesn't fit into the player's inventory.</p>
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who's collecting the pickup" },
|
||||
{ Name = "Pickup", Type = "{{cPickup}}", Notes = "The pickup being collected" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, MCServer calls other plugins' callbacks and finally the
|
||||
pickup is collected. If the function returns true, no other plugins are called for this event and
|
||||
the pickup is not collected.
|
||||
]],
|
||||
}, -- HOOK_COLLECTING_PICKUP
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_CRAFTING_NO_RECIPE =
|
||||
{
|
||||
CalledWhen = " No built-in crafting recipe is found. Plugin may provide a recipe.",
|
||||
DefaultFnName = "OnCraftingNoRecipe", -- also used as pagename
|
||||
Desc = [[
|
||||
This callback is called when a player places items in their {{cCraftingGrid|crafting grid}} and
|
||||
MCServer cannot find a built-in {{cCraftingRecipe|recipe}} for the combination. Plugins may provide
|
||||
a recipe for the ingredients given.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose crafting is reported in this hook" },
|
||||
{ Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "Contents of the player's crafting grid" },
|
||||
{ Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that will be used (can be filled by plugins)" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, no recipe will be used. If the function returns true, no
|
||||
other plugin will have their callback called for this event and MCServer will use the crafting
|
||||
recipe in Recipe.</p>
|
||||
<p>
|
||||
FIXME: To allow plugins give suggestions and overwrite other plugins' suggestions, we should change
|
||||
the behavior with returning false, so that the recipe will still be used, but fill the recipe with
|
||||
empty values by default.
|
||||
]],
|
||||
}, -- HOOK_CRAFTING_NO_RECIPE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_DISCONNECT =
|
||||
{
|
||||
CalledWhen = "A player has explicitly disconnected.",
|
||||
DefaultFnName = "OnDisconnect", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a client sends the disconnect packet and is about to be disconnected from
|
||||
the server.</p>
|
||||
<p>
|
||||
Note that this callback is not called if the client drops the connection or is kicked by the
|
||||
server.</p>
|
||||
<p>
|
||||
FIXME: There is no callback for "client destroying" that would be called in all circumstances.</p>
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player 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
|
||||
and finally broadcasts a disconnect message to the player's world. If the function returns true, no
|
||||
other plugins are called for this event and the disconnect message is not broadcast. In either case,
|
||||
the player is disconnected.
|
||||
]],
|
||||
}, -- HOOK_DISCONNECT
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
31
MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua
Normal file
31
MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua
Normal file
@ -0,0 +1,31 @@
|
||||
return
|
||||
{
|
||||
HOOK_EXECUTE_COMMAND =
|
||||
{
|
||||
CalledWhen = "A player executes an in-game command, or the admin issues a console command. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called.",
|
||||
DefaultFnName = "OnExecuteCommand", -- also used as pagename
|
||||
Desc = [[
|
||||
A plugin may implement a callback for this hook to intercept both in-game commands executed by the
|
||||
players and console commands executed by the server admin. The function is called for every in-game
|
||||
command sent from any player and for those server console commands that are not built in in the
|
||||
server.</p>
|
||||
<p>
|
||||
If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's
|
||||
executing the command. If the command comes from the server console, the first parameter is nil.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" },
|
||||
{ Name = "Command", Type = "table of strings", Notes = "The command and its parameters, broken into a table by spaces" },
|
||||
},
|
||||
Returns = [[
|
||||
If the plugin returns true, the command will be blocked and none of the remaining hook handlers will
|
||||
be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally
|
||||
the command will be executed.
|
||||
]],
|
||||
}, -- HOOK_EXECUTE_COMMAND
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
49
MCServer/Plugins/APIDump/Hooks/OnExploded.lua
Normal file
49
MCServer/Plugins/APIDump/Hooks/OnExploded.lua
Normal file
@ -0,0 +1,49 @@
|
||||
return
|
||||
{
|
||||
HOOK_EXPLODED =
|
||||
{
|
||||
CalledWhen = "An explosion has happened",
|
||||
DefaultFnName = "OnExploded", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after an explosion has been processed in a world.</p>
|
||||
<p>
|
||||
See also {{OnExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.</p>
|
||||
<p>
|
||||
The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT,
|
||||
etc. It also carries the identification of the actual source. The exact type of the identification
|
||||
depends on the source kind:
|
||||
<table>
|
||||
<tr><th>Source</th><th>SourceData Type</th><th>Notes</th></tr>
|
||||
<tr><td>esPrimedTNT</td><td>{{cTNTEntity}}</td><td>An exploding primed TNT entity</td></tr>
|
||||
<tr><td>esCreeper</td><td>{{cCreeper}}</td><td>An exploding creeper or charged creeper</td></tr>
|
||||
<tr><td>esBed</td><td>{{Vector3i}}</td><td>A bed exploding in the Nether or in the End. The bed coords are given.</td></tr>
|
||||
<tr><td>esEnderCrystal</td><td>{{Vector3i}}</td><td>An ender crystal exploding upon hit. The block coords are given.</td></tr>
|
||||
<tr><td>esGhastFireball</td><td>{{cGhastFireballEntity}}</td><td>A ghast fireball hitting ground or an {{cEntity|entity}}.</td></tr>
|
||||
<tr><td>esWitherSkullBlack</td><td><i>TBD</i></td><td>A black wither skull hitting ground or an {{cEntity|entity}}.</td></tr>
|
||||
<tr><td>esWitherSkullBlue</td><td><i>TBD</i></td><td>A blue wither skull hitting ground or an {{cEntity|entity}}.</td></tr>
|
||||
<tr><td>esWitherBirth</td><td><i>TBD</i></td><td>A wither boss being created</td></tr>
|
||||
<tr><td>esOther</td><td><i>TBD</i></td><td>Any other previously unspecified type.</td></tr>
|
||||
<tr><td>esPlugin</td><td>object</td><td>An explosion created by a plugin. The plugin may specify any kind of data.</td></tr>
|
||||
</table></p>
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happened" },
|
||||
{ Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" },
|
||||
{ Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion has turned random air blocks to fire (such as a ghast fireball)" },
|
||||
{ Name = "X", Type = "number", Notes = "X-coord of the explosion center" },
|
||||
{ Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" },
|
||||
{ Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" },
|
||||
{ Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." },
|
||||
{ Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event. There is no overridable behaviour.
|
||||
]],
|
||||
}, -- HOOK_EXPLODED
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
50
MCServer/Plugins/APIDump/Hooks/OnExploding.lua
Normal file
50
MCServer/Plugins/APIDump/Hooks/OnExploding.lua
Normal file
@ -0,0 +1,50 @@
|
||||
return
|
||||
{
|
||||
HOOK_EXPLODING =
|
||||
{
|
||||
CalledWhen = "An explosion is about to be processed",
|
||||
DefaultFnName = "OnExploding", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called before an explosion has been processed in a world.</p>
|
||||
<p>
|
||||
See also {{OnExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.</p>
|
||||
<p>
|
||||
The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT,
|
||||
etc. It also carries the identification of the actual source. The exact type of the identification
|
||||
depends on the source kind:
|
||||
<table>
|
||||
<tr><th>Source</th><th>SourceData Type</th><th>Notes</th></tr>
|
||||
<tr><td>esPrimedTNT</td><td>{{cTNTEntity}}</td><td>An exploding primed TNT entity</td></tr>
|
||||
<tr><td>esCreeper</td><td>{{cCreeper}}</td><td>An exploding creeper or charged creeper</td></tr>
|
||||
<tr><td>esBed</td><td>{{Vector3i}}</td><td>A bed exploding in the Nether or in the End. The bed coords are given.</td></tr>
|
||||
<tr><td>esEnderCrystal</td><td>{{Vector3i}}</td><td>An ender crystal exploding upon hit. The block coords are given.</td></tr>
|
||||
<tr><td>esGhastFireball</td><td>{{cGhastFireballEntity}}</td><td>A ghast fireball hitting ground or an {{cEntity|entity}}.</td></tr>
|
||||
<tr><td>esWitherSkullBlack</td><td><i>TBD</i></td><td>A black wither skull hitting ground or an {{cEntity|entity}}.</td></tr>
|
||||
<tr><td>esWitherSkullBlue</td><td><i>TBD</i></td><td>A blue wither skull hitting ground or an {{cEntity|entity}}.</td></tr>
|
||||
<tr><td>esWitherBirth</td><td><i>TBD</i></td><td>A wither boss being created</td></tr>
|
||||
<tr><td>esOther</td><td><i>TBD</i></td><td>Any other previously unspecified type.</td></tr>
|
||||
<tr><td>esPlugin</td><td>object</td><td>An explosion created by a plugin. The plugin may specify any kind of data.</td></tr>
|
||||
</table></p>
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happens" },
|
||||
{ Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" },
|
||||
{ Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion will turn random air blocks to fire (such as a ghast fireball)" },
|
||||
{ Name = "X", Type = "number", Notes = "X-coord of the explosion center" },
|
||||
{ Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" },
|
||||
{ Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" },
|
||||
{ Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." },
|
||||
{ Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called, and finally
|
||||
MCServer will process the explosion - destroy blocks and push + hurt entities. If the function
|
||||
returns true, no other callback is called for this event and the explosion will not occur.
|
||||
]],
|
||||
}, -- HOOK_EXPLODING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
29
MCServer/Plugins/APIDump/Hooks/OnHandshake.lua
Normal file
29
MCServer/Plugins/APIDump/Hooks/OnHandshake.lua
Normal file
@ -0,0 +1,29 @@
|
||||
return
|
||||
{
|
||||
HOOK_HANDSHAKE =
|
||||
{
|
||||
CalledWhen = "A client is connecting.",
|
||||
DefaultFnName = "OnHandshake", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a client sends the Handshake packet. At this stage, only the client IP and
|
||||
(unverified) username are known. Plugins may refuse access to the server based on this
|
||||
information.</p>
|
||||
<p>
|
||||
Note that the username is not authenticated - the authentication takes place only after this hook is
|
||||
processed.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection. Note that there's no {{cPlayer}} object for this client yet." },
|
||||
{ Name = "UserName", Type = "string", Notes = "The username presented in the packet. Note that this username is unverified." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false, the user is let in to the server. If the function returns true, no
|
||||
other plugin's callback is called, the user is kicked and the connection is closed.
|
||||
]],
|
||||
}, -- HOOK_HANDSHAKE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
30
MCServer/Plugins/APIDump/Hooks/OnHopperPullingItem.lua
Normal file
30
MCServer/Plugins/APIDump/Hooks/OnHopperPullingItem.lua
Normal file
@ -0,0 +1,30 @@
|
||||
return
|
||||
{
|
||||
HOOK_HOPPER_PULLING_ITEM =
|
||||
{
|
||||
CalledWhen = "A hopper is pulling an item from another block entity.",
|
||||
DefaultFnName = "OnHopperPullingItem", -- also used as pagename
|
||||
Desc = [[
|
||||
This callback is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from another
|
||||
block entity into its own internal storage. A plugin may decide to disallow the move by returning
|
||||
true. Note that in such a case, the hook may be called again for the same hopper, with different
|
||||
slot numbers.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" },
|
||||
{ Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pulling the item" },
|
||||
{ Name = "DstSlot", Type = "number", Notes = "The destination slot in the hopper's {{cItemGrid|internal storage}}" },
|
||||
{ Name = "SrcBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = "The block entity that is losing the item" },
|
||||
{ Name = "SrcSlot", Type = "number", Notes = "Slot in SrcBlockEntity from which the item will be pulled" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event and the hopper will not pull the item.
|
||||
]],
|
||||
}, -- HOOK_HOPPER_PULLING_ITEM
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
30
MCServer/Plugins/APIDump/Hooks/OnHopperPushingItem.lua
Normal file
30
MCServer/Plugins/APIDump/Hooks/OnHopperPushingItem.lua
Normal file
@ -0,0 +1,30 @@
|
||||
return
|
||||
{
|
||||
HOOK_HOPPER_PUSHING_ITEM =
|
||||
{
|
||||
CalledWhen = "A hopper is pushing an item into another block entity. ",
|
||||
DefaultFnName = "OnHopperPushingItem", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from its own
|
||||
internal storage into another block entity. A plugin may decide to disallow the move by returning
|
||||
true. Note that in such a case, the hook may be called again for the same hopper and block, with
|
||||
different slot numbers.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" },
|
||||
{ Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pushing the item" },
|
||||
{ Name = "SrcSlot", Type = "number", Notes = "Slot in the hopper that will lose the item" },
|
||||
{ Name = "DstBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = " The block entity that will receive the item" },
|
||||
{ Name = "DstSlot", Type = "number", Notes = " Slot in DstBlockEntity's internal storage where the item will be stored" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event and the hopper will not push the item.
|
||||
]],
|
||||
}, -- HOOK_HOPPER_PUSHING_ITEM
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
33
MCServer/Plugins/APIDump/Hooks/OnKilling.lua
Normal file
33
MCServer/Plugins/APIDump/Hooks/OnKilling.lua
Normal file
@ -0,0 +1,33 @@
|
||||
return
|
||||
{
|
||||
HOOK_KILLING =
|
||||
{
|
||||
CalledWhen = "A player or a mob is dying.",
|
||||
DefaultFnName = "OnKilling", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called whenever a {{cPawn|pawn}}'s (a player's or a mob's) health reaches zero. This
|
||||
means that the pawn is about to be killed, unless a plugin "revives" them by setting their health
|
||||
back to a positive value.</p>
|
||||
<p>
|
||||
FIXME: There is no HOOK_KILLED notification hook yet; this is deliberate because HOOK_KILLED has
|
||||
been recently renamed to HOOK_KILLING, and plugins need to be updated. Once updated, the HOOK_KILLED
|
||||
notification will be implemented.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" },
|
||||
{ Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, MCServer calls other plugins with this event. If the
|
||||
function returns true, no other plugin is called for this event.</p>
|
||||
<p>
|
||||
In either case, the victim's health is then re-checked and if it is greater than zero, the victim is
|
||||
"revived" with that health amount. If the health is less or equal to zero, the victim is killed.
|
||||
]],
|
||||
}, -- HOOK_KILLING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
31
MCServer/Plugins/APIDump/Hooks/OnLogin.lua
Normal file
31
MCServer/Plugins/APIDump/Hooks/OnLogin.lua
Normal file
@ -0,0 +1,31 @@
|
||||
return
|
||||
{
|
||||
HOOK_LOGIN =
|
||||
{
|
||||
CalledWhen = "Right before player authentication. If auth is disabled, right after the player sends their name.",
|
||||
DefaultFnName = "OnLogin", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called whenever a client logs in. It is called right before the client's name is sent
|
||||
to be authenticated. Plugins may refuse the client from accessing the server. Note that when this
|
||||
callback is called, the {{cPlayer}} object for this client doesn't exist yet - the client has no
|
||||
representation in any world. To process new players when their world is known, use a later callback,
|
||||
such as {{OnPlayerJoined|HOOK_PLAYER_JOINED}} or {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection" },
|
||||
{ Name = "ProtocolVersion", Type = "number", Notes = "Versio of the protocol that the client is talking" },
|
||||
{ Name = "UserName", Type = "string", Notes = "The name that the client has presented for authentication. This name will be given to the {{cPlayer}} object when it is created for this client." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns true, no other plugins are called for this event and the client is kicked.
|
||||
If the function returns false or no value, MCServer calls other plugins' callbacks and finally
|
||||
sends an authentication request for the client's username to the auth server. If the auth server
|
||||
is disabled in the server settings, the player object is immediately created.
|
||||
]],
|
||||
}, -- HOOK_LOGIN
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
28
MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua
Normal file
28
MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua
Normal file
@ -0,0 +1,28 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_ANIMATION =
|
||||
{
|
||||
CalledWhen = "A client has sent an Animation packet (0x12)",
|
||||
DefaultFnName = "OnPlayerAnimation", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when the server receives an Animation packet (0x12) from the client.</p>
|
||||
<p>
|
||||
For the list of animations that are sent by the client, see the
|
||||
<a href="http://wiki.vg/Protocol#0x12">Protocol wiki</a>.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" },
|
||||
{ Name = "Animation", Type = "number", Notes = "The kind of animation" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
|
||||
server broadcasts the animation packet to all nearby clients. If the function returns true, no other
|
||||
callback is called for this event and the packet is not broadcasted.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_ANIMATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
36
MCServer/Plugins/APIDump/Hooks/OnPlayerBreakingBlock.lua
Normal file
36
MCServer/Plugins/APIDump/Hooks/OnPlayerBreakingBlock.lua
Normal file
@ -0,0 +1,36 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_BREAKING_BLOCK =
|
||||
{
|
||||
CalledWhen = "Just before a player breaks a block. Plugin may override / refuse. ",
|
||||
DefaultFnName = "OnPlayerBreakingBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a {{cPlayer|player}} breaks a block, before the block is actually broken in
|
||||
the {{cWorld|World}}. Plugins may refuse the breaking.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after
|
||||
the block is broken.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is digging the block" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player is acting. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block being broken" },
|
||||
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block being broken " },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called, and then the block
|
||||
is broken. If the function returns true, no other plugin's callback is called and the block breaking
|
||||
is cancelled. The server re-sends the block back to the player to replace it (the player's client
|
||||
already thinks the block was broken).
|
||||
]],
|
||||
}, -- HOOK_PLAYER_BREAKING_BLOCK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
36
MCServer/Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua
Normal file
36
MCServer/Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua
Normal file
@ -0,0 +1,36 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_BROKEN_BLOCK =
|
||||
{
|
||||
CalledWhen = "After a player has broken a block. Notification only.",
|
||||
DefaultFnName = "OnPlayerBrokenBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This function is called after a {{cPlayer|player}} breaks a block. The block is already removed
|
||||
from the {{cWorld|world}} and {{cPickup|pickups}} have been spawned. To get the world in which the
|
||||
block has been dug, use the {{cPlayer}}:GetWorld() function.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK}} hook for a similar hook called
|
||||
before the block is broken. To intercept the creation of pickups, see the
|
||||
{{OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS}} hook.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who broke the block" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
|
||||
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_BROKEN_BLOCK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
27
MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua
Normal file
27
MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua
Normal file
@ -0,0 +1,27 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_EATING =
|
||||
{
|
||||
CalledWhen = "When the player starts eating",
|
||||
DefaultFnName = "OnPlayerEating", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook gets called when the {{cPlayer|player}} starts eating, after the server checks that the
|
||||
player can indeed eat (is not satiated and is holding food). Plugins may still refuse the eating by
|
||||
returning true.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who started eating" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the server calls the next plugin handler, and finally
|
||||
lets the player eat. If the function returns true, the server doesn't call any more callbacks for
|
||||
this event and aborts the eating. A "disallow" packet is sent to the client.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_EATING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
29
MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua
Normal file
29
MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua
Normal file
@ -0,0 +1,29 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_JOINED =
|
||||
{
|
||||
CalledWhen = "After Login and before Spawned, before being added to world. ",
|
||||
DefaultFnName = "OnPlayerJoined", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called whenever a {{cPlayer|player}} has completely logged in. If authentication is
|
||||
enabled, this function is called after their name has been authenticated. It is called after
|
||||
{{OnLogin|HOOK_LOGIN}} and before {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}, right after the player's
|
||||
entity is created, but not added to the world yet. The player is not yet visible to other players.
|
||||
This is a notification-only event, plugins wishing to refuse player's entry should kick the player
|
||||
using the {{cPlayer}}:Kick() function.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has joined the game" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called for this event. Either way the player is let in.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_JOINED
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
47
MCServer/Plugins/APIDump/Hooks/OnPlayerLeftClick.lua
Normal file
47
MCServer/Plugins/APIDump/Hooks/OnPlayerLeftClick.lua
Normal file
@ -0,0 +1,47 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_LEFT_CLICK =
|
||||
{
|
||||
CalledWhen = "A left-click packet is received from the client. Plugin may override / refuse.",
|
||||
DefaultFnName = "OnPlayerLeftClick", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when MCServer receives a left-click packet from the {{cClientHandle|client}}. It
|
||||
is called before any processing whatsoever is performed on the packet, meaning that hacked /
|
||||
malicious clients may be trigerring this event very often and with unchecked parameters. Therefore
|
||||
plugin authors are advised to use extreme caution with this callback.</p>
|
||||
<p>
|
||||
Plugins may refuse the default processing for the packet, causing MCServer to behave as if the
|
||||
packet has never arrived. This may, however, create inconsistencies in the client - the client may
|
||||
think that they broke a block, while the server didn't process the breaking, etc. For this reason,
|
||||
if a plugin refuses the processing, MCServer sends the block specified in the packet back to the
|
||||
client (as if placed anew), if the status code specified a block-break action. For other actions,
|
||||
plugins must rectify the situation on their own.</p>
|
||||
<p>
|
||||
The client sends the left-click packet for several other occasions, such as dropping the held item
|
||||
(Q keypress) or shooting an arrow. This is reflected in the Status code. Consult the
|
||||
<a href="http://wiki.vg/Protocol#0x0E">protocol documentation</a> for details on the actions.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "Action", Type = "number", Notes = "Action to be performed on the block (\"status\" in the protocol docs)" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends
|
||||
the packet for further processing.</p>
|
||||
<p>
|
||||
If the function returns true, no other plugins are called, processing is halted. If the action was a
|
||||
block dig, MCServer sends the block specified in the coords back to the client. The packet is
|
||||
dropped.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_LEFT_CLICK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
27
MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua
Normal file
27
MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua
Normal file
@ -0,0 +1,27 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_MOVING =
|
||||
{
|
||||
CalledWhen = "Player tried to move in the tick being currently processed. Plugin may refuse movement.",
|
||||
DefaultFnName = "OnPlayerMoving", -- also used as pagename
|
||||
Desc = [[
|
||||
This function is called in each server tick for each {{cPlayer|player}} that has sent any of the
|
||||
player-move packets. Plugins may refuse the movement.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has moved. The object already has the new position stored in it." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns true, movement is prohibited. FIXME: The player's client is not informed.</p>
|
||||
<p>
|
||||
If the function returns false or no value, other plugins' callbacks are called and finally the new
|
||||
position is permanently stored in the cPlayer object.</p>
|
||||
]],
|
||||
}, -- HOOK_PLAYER_MOVING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
40
MCServer/Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua
Normal file
40
MCServer/Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua
Normal file
@ -0,0 +1,40 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_PLACED_BLOCK =
|
||||
{
|
||||
CalledWhen = "After a player has placed a block. Notification only.",
|
||||
DefaultFnName = "OnPlayerPlacedBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a {{cPlayer|player}} has placed a block in the {{cWorld|world}}. The block
|
||||
is already added to the world and the corresponding item removed from player's
|
||||
{{cInventory|inventory}}.</p>
|
||||
<p>
|
||||
Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK}} hook for a similar hook called
|
||||
before the placement.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who placed the block" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player interacted. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" },
|
||||
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
|
||||
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
|
||||
},
|
||||
Returns = [[
|
||||
If this function returns false or no value, MCServer calls other plugins with the same event. If
|
||||
this function returns true, no other plugin is called for this event.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_PLACED_BLOCK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
45
MCServer/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua
Normal file
45
MCServer/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua
Normal file
@ -0,0 +1,45 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_PLACING_BLOCK =
|
||||
{
|
||||
CalledWhen = "Just before a player places a block. Plugin may override / refuse.",
|
||||
DefaultFnName = "OnPlayerPlacingBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called just before a {{cPlayer|player}} places a block in the {{cWorld|world}}. The
|
||||
block is not yet placed, plugins may choose to override the default behavior or refuse the placement
|
||||
at all.</p>
|
||||
<p>
|
||||
Note that the client already expects that the block has been placed. For that reason, if a plugin
|
||||
refuses the placement, MCServer sends the old block at the provided coords to the client.</p>
|
||||
<p>
|
||||
Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after
|
||||
the placement.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is placing the block" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player is interacting. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" },
|
||||
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
|
||||
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
|
||||
},
|
||||
Returns = [[
|
||||
If this function returns false or no value, MCServer calls other plugins with the same event and
|
||||
finally places the block and removes the corresponding item from player's inventory. If this
|
||||
function returns true, no other plugin is called for this event, MCServer sends the old block at
|
||||
the specified coords to the client and drops the packet.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_PLACING_BLOCK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
40
MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua
Normal file
40
MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua
Normal file
@ -0,0 +1,40 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_RIGHT_CLICK =
|
||||
{
|
||||
CalledWhen = "A right-click packet is received from the client. Plugin may override / refuse.",
|
||||
DefaultFnName = "OnPlayerRightClick", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when MCServer receives a right-click packet from the {{cClientHandle|client}}. It
|
||||
is called before any processing whatsoever is performed on the packet, meaning that hacked /
|
||||
malicious clients may be trigerring this event very often and with unchecked parameters. Therefore
|
||||
plugin authors are advised to use extreme caution with this callback.</p>
|
||||
<p>
|
||||
Plugins may refuse the default processing for the packet, causing MCServer to behave as if the
|
||||
packet has never arrived. This may, however, create inconsistencies in the client - the client may
|
||||
think that they placed a block, while the server didn't process the placing, etc.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the mouse crosshair on the block" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the mouse crosshair on the block" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the mouse crosshair on the block" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends
|
||||
the packet for further processing.</p>
|
||||
<p>
|
||||
If the function returns true, no other plugins are called, processing is halted.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_RIGHT_CLICK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_RIGHT_CLICKING_ENTITY =
|
||||
{
|
||||
CalledWhen = "A player has right-clicked an entity. Plugins may override / refuse.",
|
||||
DefaultFnName = "OnPlayerRightClickingEntity", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when the {{cPlayer|player}} right-clicks an {{cEntity|entity}}. Plugins may
|
||||
override the default behavior or even cancel the default processing.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has right-clicked the entity" },
|
||||
{ Name = "Entity", Type = "{{cEntity}} descendant", Notes = "The entity that has been right-clicked" },
|
||||
},
|
||||
Returns = [[
|
||||
If the functino returns false or no value, MCServer calls other plugins' callbacks and finally does
|
||||
the default processing for the right-click. If the function returns true, no other callbacks are
|
||||
called and the default processing is skipped.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_RIGHT_CLICKING_ENTITY
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnPlayerShooting.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnPlayerShooting.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_SHOOTING =
|
||||
{
|
||||
CalledWhen = "When the player releases the bow, shooting an arrow (other projectiles: unknown)",
|
||||
DefaultFnName = "OnPlayerShooting", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when the {{cPlayer|player}} shoots their bow. It is called for the actual
|
||||
release of the {{cArrowEntity|arrow}}. FIXME: It is currently unknown whether other
|
||||
{{cProjectileEntity|projectiles}} (snowballs, eggs) trigger this hook.</p>
|
||||
<p>
|
||||
To get the player's position and direction, use the {{cPlayer}}:GetEyePosition() and
|
||||
cPlayer:GetLookVector() functions. Note that for shooting a bow, the position for the arrow creation
|
||||
is not at the eye pos, some adjustments are required. FIXME: Export the {{cPlayer}} function for
|
||||
this adjustment.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player shooting" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called, and finally
|
||||
MCServer creates the projectile. If the functino returns true, no other callback is called and no
|
||||
projectile is created.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_SHOOTING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_SPAWNED =
|
||||
{
|
||||
CalledWhen = "After a player (re)spawns in the world to which they belong to.",
|
||||
DefaultFnName = "OnPlayerSpawned", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a {{cPlayer|player}} has spawned in the world. It is called after
|
||||
{{OnLogin|HOOK_LOGIN}} and {{OnPlayerJoined|HOOK_PLAYER_JOINED}}, after the player name has been
|
||||
authenticated, the initial worldtime, inventory and health have been sent to the player and the
|
||||
player spawn packet has been broadcast to all players near enough to the player spawn place. This is
|
||||
a notification-only event, plugins wishing to refuse player's entry should kick the player using the
|
||||
{{cPlayer}}:Kick() function.</p>
|
||||
<p>
|
||||
This hook is also called when the player respawns after death (and a respawn packet is received from
|
||||
the client, meaning the player has already clicked the Respawn button).
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has (re)spawned" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called for this event. There is no overridable behavior.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_SPAWNED
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
30
MCServer/Plugins/APIDump/Hooks/OnPlayerTossingItem.lua
Normal file
30
MCServer/Plugins/APIDump/Hooks/OnPlayerTossingItem.lua
Normal file
@ -0,0 +1,30 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_TOSSING_ITEM =
|
||||
{
|
||||
CalledWhen = "A player is tossing an item. Plugin may override / refuse.",
|
||||
DefaultFnName = "OnPlayerTossingItem", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a {{cPlayer|player}} has tossed an item (Q keypress). The
|
||||
{{cPickup|pickup}} has not been spawned yet. Plugins may disallow the tossing, but in that case they
|
||||
need to clean up - the player's client already thinks the item has been tossed so the
|
||||
{{cInventory|inventory}} needs to be re-sent to the player.</p>
|
||||
<p>
|
||||
To get the item that is about to be tossed, call the {{cPlayer}}:GetEquippedItem() function.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player tossing an item" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called and finally MCServer
|
||||
creates the pickup for the item and tosses it, using {{cPlayer}}:TossItem. If the function returns
|
||||
true, no other callbacks are called for this event and MCServer doesn't toss the item.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_TOSSING_ITEM
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
46
MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua
Normal file
46
MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua
Normal file
@ -0,0 +1,46 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_USED_BLOCK =
|
||||
{
|
||||
CalledWhen = "A player has just used a block (chest, furnace…). Notification only.",
|
||||
DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a
|
||||
{{cChestEntity|chest}} or a lever. It is called after MCServer processes the usage (sends the UI
|
||||
handling packets / toggles redstone). Note that for UI-related blocks, the player is most likely
|
||||
still using the UI. This is a notification-only event.</p>
|
||||
<p>
|
||||
Note that the block coords given in this callback are for the (solid) block that is being clicked,
|
||||
not the air block between it and the player.</p>
|
||||
<p>
|
||||
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} for a similar hook called before the
|
||||
use, the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}}
|
||||
for similar hooks called when a player interacts with any block with a usable item in hand, such as
|
||||
a bucket.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the block" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
|
||||
{ Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called for this event.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_USED_BLOCK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
46
MCServer/Plugins/APIDump/Hooks/OnPlayerUsedItem.lua
Normal file
46
MCServer/Plugins/APIDump/Hooks/OnPlayerUsedItem.lua
Normal file
@ -0,0 +1,46 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_USED_ITEM =
|
||||
{
|
||||
CalledWhen = "A player has used an item in hand (bucket...)",
|
||||
DefaultFnName = "OnPlayerUsedItem", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that
|
||||
can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a
|
||||
hoe. It is called after MCServer processes the usage (places fluid / turns dirt to farmland).
|
||||
This is an information-only hook, there is no way to cancel the event anymore.</p>
|
||||
<p>
|
||||
Note that the block coords given in this callback are for the (solid) block that is being clicked,
|
||||
not the air block between it and the player.</p>
|
||||
<p>
|
||||
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get
|
||||
the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} for a similar hook called before the use,
|
||||
the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}}
|
||||
for similar hooks called when a player interacts with a block, such as a chest.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the item" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
|
||||
{ Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called for this event.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_USED_ITEM
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
46
MCServer/Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua
Normal file
46
MCServer/Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua
Normal file
@ -0,0 +1,46 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_USING_BLOCK =
|
||||
{
|
||||
CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.",
|
||||
DefaultFnName = "OnPlayerUsingBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a {{cPlayer|player}} has right-clicked a block that can be used, such as a
|
||||
{{cChestEntity|chest}} or a lever. It is called before MCServer processes the usage (sends the UI
|
||||
handling packets / toggles redstone). Plugins may refuse the interaction by returning true.</p>
|
||||
<p>
|
||||
Note that the block coords given in this callback are for the (solid) block that is being clicked,
|
||||
not the air block between it and the player.</p>
|
||||
<p>
|
||||
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for a similar hook called after the use, the
|
||||
{{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for
|
||||
similar hooks called when a player interacts with any block with a usable item in hand, such as a
|
||||
bucket.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the block" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
|
||||
{ Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called and then MCServer
|
||||
processes the interaction. If the function returns true, no other callbacks are called for this
|
||||
event and the interaction is silently dropped.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_USING_BLOCK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
47
MCServer/Plugins/APIDump/Hooks/OnPlayerUsingItem.lua
Normal file
47
MCServer/Plugins/APIDump/Hooks/OnPlayerUsingItem.lua
Normal file
@ -0,0 +1,47 @@
|
||||
return
|
||||
{
|
||||
HOOK_PLAYER_USING_ITEM =
|
||||
{
|
||||
CalledWhen = "Just before a player uses an item in hand (bucket...). Plugin may override / refuse.",
|
||||
DefaultFnName = "OnPlayerUsingItem", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that
|
||||
can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a
|
||||
hoe. It is called before MCServer processes the usage (places fluid / turns dirt to farmland).
|
||||
Plugins may refuse the interaction by returning true.</p>
|
||||
<p>
|
||||
Note that the block coords given in this callback are for the (solid) block that is being clicked,
|
||||
not the air block between it and the player.</p>
|
||||
<p>
|
||||
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get
|
||||
the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.</p>
|
||||
<p>
|
||||
See also the {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for a similar hook called after the use, the
|
||||
{{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for
|
||||
similar hooks called when a player interacts with a block, such as a chest.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the item" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
|
||||
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
|
||||
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
|
||||
{ Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
|
||||
{ Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called and then MCServer
|
||||
processes the interaction. If the function returns true, no other callbacks are called for this
|
||||
event and the interaction is silently dropped.
|
||||
]],
|
||||
}, -- HOOK_PLAYER_USING_ITEM
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
36
MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua
Normal file
36
MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua
Normal file
@ -0,0 +1,36 @@
|
||||
return
|
||||
{
|
||||
HOOK_POST_CRAFTING =
|
||||
{
|
||||
CalledWhen = "After the built-in recipes are checked and a recipe was found.",
|
||||
DefaultFnName = "OnPostCrafting", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a {{cPlayer|player}} changes contents of their
|
||||
{{cCraftingGrid|crafting grid}}, after the recipe has been established by MCServer. Plugins may use
|
||||
this to modify the resulting recipe or provide an alternate recipe.</p>
|
||||
<p>
|
||||
If a plugin implements custom recipes, it should do so using the {{OnPreCrafting|HOOK_PRE_CRAFTING}}
|
||||
hook, because that will save the server from going through the built-in recipes. The
|
||||
HOOK_POST_CRAFTING hook is intended as a notification, with a chance to tweak the result.</p>
|
||||
<p>
|
||||
Note that this hook is not called if a built-in recipe is not found;
|
||||
{{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}} is called instead in such a case.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" },
|
||||
{ Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" },
|
||||
{ Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer has decided to use (can be tweaked by plugins)" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called for this event. In either case, MCServer uses the value
|
||||
of Recipe as the recipe to be presented to the player.
|
||||
]],
|
||||
}, -- HOOK_POST_CRAFTING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
37
MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua
Normal file
37
MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua
Normal file
@ -0,0 +1,37 @@
|
||||
return
|
||||
{
|
||||
HOOK_PRE_CRAFTING =
|
||||
{
|
||||
CalledWhen = "Before the built-in recipes are checked.",
|
||||
DefaultFnName = "OnPreCrafting", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a {{cPlayer|player}} changes contents of their
|
||||
{{cCraftingGrid|crafting grid}}, before the built-in recipes are searched for a match by MCServer.
|
||||
Plugins may use this hook to provide a custom recipe.</p>
|
||||
<p>
|
||||
If you intend to tweak built-in recipes, use the {{OnPostCrafting|HOOK_POST_CRAFTING}} hook, because
|
||||
that will be called once the built-in recipe is matched.</p>
|
||||
<p>
|
||||
Also note a third hook, {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}}, that is called when MCServer
|
||||
cannot find any built-in recipe for the given ingredients.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" },
|
||||
{ Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" },
|
||||
{ Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer will use. Modify this object to change the recipe" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called and then MCServer
|
||||
searches the built-in recipes. The Recipe output parameter is ignored in this case.</p>
|
||||
<p>
|
||||
If the function returns true, no other callbacks are called for this event and MCServer uses the
|
||||
recipe stored in the Recipe output parameter.
|
||||
]],
|
||||
}, -- HOOK_PRE_CRAFTING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
31
MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua
Normal file
31
MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua
Normal file
@ -0,0 +1,31 @@
|
||||
return
|
||||
{
|
||||
HOOK_SPAWNED_ENTITY =
|
||||
{
|
||||
CalledWhen = "After an entity is spawned in the world.",
|
||||
DefaultFnName = "OnSpawnedEntity", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after the server spawns an {{cEntity|entity}}. This is an information-only
|
||||
callback, the entity is already spawned by the time it is called. If the entity spawned is a
|
||||
{{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this
|
||||
hook.</p>
|
||||
<p>
|
||||
See also the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} hook for a similar hook called before the
|
||||
entity is spawned.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity has spawned" },
|
||||
{ Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that has spawned" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event.
|
||||
]],
|
||||
}, -- HOOK_SPAWNED_ENTITY
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
30
MCServer/Plugins/APIDump/Hooks/OnSpawnedMonster.lua
Normal file
30
MCServer/Plugins/APIDump/Hooks/OnSpawnedMonster.lua
Normal file
@ -0,0 +1,30 @@
|
||||
return
|
||||
{
|
||||
HOOK_SPAWNED_MONSTER =
|
||||
{
|
||||
CalledWhen = "After a monster is spawned in the world",
|
||||
DefaultFnName = "OnSpawnedMonster", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only
|
||||
callback, the monster is already spawned by the time it is called. After this hook is called, the
|
||||
{{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity.</p>
|
||||
<p>
|
||||
See also the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook for a similar hook called before the
|
||||
monster is spawned.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the monster has spawned" },
|
||||
{ Name = "Monster", Type = "{{cMonster}} descendant", Notes = "The monster that has spawned" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event.
|
||||
]],
|
||||
}, -- HOOK_SPAWNED_MONSTER
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_SPAWNING_ENTITY =
|
||||
{
|
||||
CalledWhen = "Before an entity is spawned in the world.",
|
||||
DefaultFnName = "OnSpawningEntity", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the
|
||||
entity before it is spawned, or disable the spawning altogether. If the entity spawning is a
|
||||
monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook is called before this hook.</p>
|
||||
<p>
|
||||
See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the
|
||||
entity is spawned.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" },
|
||||
{ Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that will spawn" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. Finally, the server
|
||||
spawns the entity with whatever parameters have been set on the {{cEntity}} object by the callbacks.
|
||||
If the function returns true, no other callback is called for this event and the entity is not
|
||||
spawned.
|
||||
]],
|
||||
}, -- HOOK_SPAWNING_ENTITY
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
33
MCServer/Plugins/APIDump/Hooks/OnSpawningMonster.lua
Normal file
33
MCServer/Plugins/APIDump/Hooks/OnSpawningMonster.lua
Normal file
@ -0,0 +1,33 @@
|
||||
return
|
||||
{
|
||||
HOOK_SPAWNING_MONSTER =
|
||||
{
|
||||
CalledWhen = "Before a monster is spawned in the world.",
|
||||
DefaultFnName = "OnSpawningMonster", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called before the server spawns a {{cMonster|monster}}. The plugins may modify the
|
||||
monster's parameters in the {{cMonster}} class, or disallow the spawning altogether. This hook is
|
||||
called before the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} is called for the monster entity.</p>
|
||||
<p>
|
||||
See also the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook for a similar hook called after the
|
||||
monster is spawned.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" },
|
||||
{ Name = "Monster", Type = "{{cMonster}} descentant", Notes = "The monster that will spawn" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. Finally, the server
|
||||
spawns the monster with whatever parameters the plugins set in the cMonster parameter.</p>
|
||||
<p>
|
||||
If the function returns true, no other callback is called for this event and the monster won't
|
||||
spawn.
|
||||
]],
|
||||
}, -- HOOK_SPAWNING_MONSTER
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
31
MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua
Normal file
31
MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua
Normal file
@ -0,0 +1,31 @@
|
||||
return
|
||||
{
|
||||
HOOK_TAKE_DAMAGE =
|
||||
{
|
||||
CalledWhen = "An {{cEntity|entity}} is taking any kind of damage",
|
||||
DefaultFnName = "OnTakeDamage", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when any {{cEntity}} descendant, such as a {{cPlayer|player}} or a
|
||||
{{cMonster|mob}}, takes any kind of damage. The plugins may modify the amount of damage or effects
|
||||
with this hook by editting the {{TakeDamageInfo}} object passed.</p>
|
||||
<p>
|
||||
This hook is called after the final damage is calculated, including all the possible weapon
|
||||
{{cEnchantments|enchantments}}, armor protection and potion effects.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "Receiver", Type = "{{cEntity}} descendant", Notes = "The entity taking damage" },
|
||||
{ Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects. Plugins may modify this object to alter the final damage applied." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called and then the server
|
||||
applies the final values from the TDI object to Receiver. If the function returns true, no other
|
||||
callbacks are called, and no damage nor effects are applied.
|
||||
]],
|
||||
}, -- HOOK_TAKE_DAMAGE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
29
MCServer/Plugins/APIDump/Hooks/OnTick.lua
Normal file
29
MCServer/Plugins/APIDump/Hooks/OnTick.lua
Normal file
@ -0,0 +1,29 @@
|
||||
return
|
||||
{
|
||||
HOOK_TICK =
|
||||
{
|
||||
CalledWhen = "Every server tick (approximately 20 times per second)",
|
||||
DefaultFnName = "OnTick", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called every game tick (50 msec, or 20 times a second). If the server is overloaded,
|
||||
the interval is larger, which is indicated by the TimeDelta parameter.</p>
|
||||
<p>
|
||||
This hook is called in the context of the server-tick thread, that is, the thread that takes care of
|
||||
{{cClientHandle|client connections}} before they're assigned to {{cPlayer|player entities}}, and
|
||||
processing console commands.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds elapsed since the last server tick. Will not be less than 50 msec." },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called. There is no overridable behavior.
|
||||
]],
|
||||
}, -- HOOK_TICK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
38
MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua
Normal file
38
MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua
Normal file
@ -0,0 +1,38 @@
|
||||
return
|
||||
{
|
||||
HOOK_UPDATED_SIGN =
|
||||
{
|
||||
CalledWhen = "After the sign text is updated. Notification only.",
|
||||
DefaultFnName = "OnUpdatedSign", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a sign has had its text updated. The text is already updated at this
|
||||
point.</p>
|
||||
<p>The update may have been caused either by a {{cPlayer|player}} directly updating the sign, or by
|
||||
a plugin changing the sign text using the API.</p>
|
||||
<p>
|
||||
See also the {{OnUpdatingSign|HOOK_UPDATING_SIGN}} hook for a similar hook called before the update,
|
||||
with a chance to modify the text.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the sign" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" },
|
||||
{ Name = "Line1", Type = "string", Notes = "1st line of the new text" },
|
||||
{ Name = "Line2", Type = "string", Notes = "2nd line of the new text" },
|
||||
{ Name = "Line3", Type = "string", Notes = "3rd line of the new text" },
|
||||
{ Name = "Line4", Type = "string", Notes = "4th line of the new text" },
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." }
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, other plugins' callbacks are called. If the function
|
||||
returns true, no other callbacks are called. There is no overridable behavior.
|
||||
]],
|
||||
}, -- HOOK_UPDATED_SIGN
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
58
MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua
Normal file
58
MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua
Normal file
@ -0,0 +1,58 @@
|
||||
return
|
||||
{
|
||||
HOOK_UPDATING_SIGN =
|
||||
{
|
||||
CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.",
|
||||
DefaultFnName = "OnUpdatingSign", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when a sign text is about to be updated, either as a result of player's
|
||||
manipulation or any other event, such as a plugin setting the sign text. Plugins may modify the text
|
||||
or refuse the update altogether.</p>
|
||||
<p>
|
||||
See also the {{OnUpdatedSign|HOOK_UPDATED_SIGN}} hook for a similar hook called after the update.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" },
|
||||
{ Name = "BlockX", Type = "number", Notes = "X-coord of the sign" },
|
||||
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" },
|
||||
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" },
|
||||
{ Name = "Line1", Type = "string", Notes = "1st line of the new text" },
|
||||
{ Name = "Line2", Type = "string", Notes = "2nd line of the new text" },
|
||||
{ Name = "Line3", Type = "string", Notes = "3rd line of the new text" },
|
||||
{ Name = "Line4", Type = "string", Notes = "4th line of the new text" },
|
||||
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." }
|
||||
},
|
||||
Returns = [[
|
||||
The function may return up to five values. If the function returns true as the first value, no other
|
||||
callbacks are called for this event and the sign is not updated. If the function returns no value or
|
||||
false as its first value, other plugins' callbacks are called.</p>
|
||||
<p>
|
||||
The other up to four values returned are used to update the sign text, line by line, respectively.
|
||||
Note that other plugins may again update the texts (if the first value returned is false).
|
||||
]],
|
||||
CodeExamples =
|
||||
{
|
||||
{
|
||||
Title = "Add player signature",
|
||||
Desc = "The following example appends a player signature to the last line, if the sign is updated by a player:",
|
||||
Code = [[
|
||||
function OnUpdatingSign(World, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player)
|
||||
if (Player == nil) then
|
||||
-- Not changed by a player
|
||||
return false;
|
||||
end
|
||||
|
||||
-- Sign with playername, allow other plugins to interfere:
|
||||
return false, Line1, Line2, Line3, Line4 .. Player:GetName();
|
||||
end
|
||||
]],
|
||||
}
|
||||
} ,
|
||||
}, -- HOOK_UPDATING_SIGN
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
28
MCServer/Plugins/APIDump/Hooks/OnWeatherChanged.lua
Normal file
28
MCServer/Plugins/APIDump/Hooks/OnWeatherChanged.lua
Normal file
@ -0,0 +1,28 @@
|
||||
return
|
||||
{
|
||||
HOOK_WEATHER_CHANGED =
|
||||
{
|
||||
CalledWhen = "The weather has changed",
|
||||
DefaultFnName = "OnWeatherChanged", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after the weather has changed in a {{cWorld|world}}. The new weather has already
|
||||
been sent to the clients.</p>
|
||||
<p>
|
||||
See also the {{OnWeatherChanging|HOOK_WEATHER_CHANGING}} hook for a similar hook called before the
|
||||
change.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather has changed" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event. There is no overridable behavior.
|
||||
]],
|
||||
}, -- HOOK_WEATHER_CHANGED
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
32
MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua
Normal file
32
MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return
|
||||
{
|
||||
HOOK_WEATHER_CHANGING =
|
||||
{
|
||||
CalledWhen = "The weather is about to change",
|
||||
DefaultFnName = "OnWeatherChanging", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called when the current weather has expired and a new weather is selected. Plugins may
|
||||
override the new weather setting.</p>
|
||||
<p>
|
||||
The new weather setting is sent to the clients only after this hook has been processed.</p>
|
||||
<p>
|
||||
See also the {{OnWeatherChanged|HOOK_WEATHER_CHANGED}} hook for a similar hook called after the
|
||||
change.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather is changing" },
|
||||
{ Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the server calls other plugins' callbacks and finally
|
||||
sets the weather. If the function returns true, the server takes the second returned value (wSunny
|
||||
by default) and sets it as the new weather. No other plugins' callbacks are called in this case.
|
||||
]],
|
||||
}, -- HOOK_WEATHER_CHANGING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
29
MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua
Normal file
29
MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua
Normal file
@ -0,0 +1,29 @@
|
||||
return
|
||||
{
|
||||
HOOK_WORLD_TICK =
|
||||
{
|
||||
CalledWhen = "Every world tick (about 20 times per second), separately for each world",
|
||||
DefaultFnName = "OnWorldTick", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called for each {{cWorld|world}} every tick (50 msec, or 20 times a second). If the
|
||||
world is overloaded, the interval is larger, which is indicated by the TimeDelta parameter.</p>
|
||||
<p>
|
||||
This hook is called in the world's tick thread context and thus has access to all world data
|
||||
guaranteed without blocking.
|
||||
]],
|
||||
Params =
|
||||
{
|
||||
{ Name = "World", Type = "{{cWorld}}", Notes = "World that is ticking" },
|
||||
{ Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds since the previous game tick. Will not be less than 50 msec" },
|
||||
},
|
||||
Returns = [[
|
||||
If the function returns false or no value, the next plugin's callback is called. If the function
|
||||
returns true, no other callback is called for this event. There is no overridable behavior.
|
||||
]],
|
||||
}, -- HOOK_WORLD_TICK
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
191
MCServer/Plugins/APIDump/LICENSE-prettify.txt
Normal file
191
MCServer/Plugins/APIDump/LICENSE-prettify.txt
Normal file
@ -0,0 +1,191 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2011 Mike Samuel et al
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
69
MCServer/Plugins/APIDump/WebWorldThreads.html
Normal file
69
MCServer/Plugins/APIDump/WebWorldThreads.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>MCServer - Webserver vs World threads</title>
|
||||
<link rel="stylesheet" type="text/css" href="main.css" />
|
||||
<link rel="stylesheet" type="text/css" href="prettify.css" />
|
||||
<script src="prettify.js"></script>
|
||||
<script src="lang-lua.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Webserver vs World threads</h1>
|
||||
<p>
|
||||
This article will explain the threading issues that arise between the webserver and world threads are of concern to plugin authors.</p>
|
||||
<p>
|
||||
Generally, plugins that provide webadmin pages should be quite careful about their interactions. Most operations on MCServer objects requires synchronization, that MCServer provides automatically and transparently to plugins - when a block is written, the chunkmap is locked, or when an entity is being manipulated, the entity list is locked. Each plugin also has a mutex lock, so that only one thread at a time may be executing plugin code.</p>
|
||||
<p>
|
||||
This locking can be a source of deadlocks for plugins that are not written carefully.</p>
|
||||
|
||||
<h2>Example scenario</h2>
|
||||
<p>Consider the following example. A plugin provides a webadmin page that allows the admin to kick players off the server. When the admin presses the "Kick" button, the plugin calls cWorld:DoWithPlayer() with a callback to kick the player. Everything seems to be working fine now.</p>
|
||||
<p>
|
||||
A new feature is developed in the plugin, now the plugin adds a new in-game command so that the admins can kick players while they're playing the game. The plugin registers a command callback with cPluginManager.AddCommand(). Now there are problems bound to happen.</p>
|
||||
<p>
|
||||
Suppose that two admins are in, one is using the webadmin and the other is in-game. Both try to kick a player at the same time. The webadmin locks the plugin, so that it can execute the plugin code, but right at this moment the OS switches threads. The world thread locks the world so that it can access the list of in-game commands, receives the in-game command, it tries to lock the plugin. The plugin is already locked, so the world thread is put on hold. After a while, the webadmin thread is woken up again and continues processing. It tries to lock the world so that it can traverse the playerlist, but the lock is already held by the world thread. Now both threads are holding one lock each and trying to grab the other lock, and are therefore deadlocked.</p>
|
||||
|
||||
<h2>How to avoid the deadlock</h2>
|
||||
<p>
|
||||
There are two main ways to avoid such a deadlock. The first approach is using tasks: Everytime you need to execute a task inside a world, instead of executing it, queue it, using <a href="cWorld.html">cWorld</a>:QueueTask(). This handy utility can will call the given function inside the world's TickThread, thus eliminating the deadlock, because now there's only one thread. However, this approach will not let you get data back. You cannot query the player list, or the entities, or anything - because when the task runs, the webadmin page has already been served to the browser.</p>
|
||||
<p>
|
||||
To accommodate this, you'll need to use the second approach - preparing and caching data in the tick thread, possibly using callbacks. This means that the plugin will have global variables that will store the data, and update those variables when the data changes; then the webserver thread will only read those variables, instead of calling the world functions. For example, if a webpage was to display the list of currently connected players, the plugin should maintain a global variable, g_WorldPlayers, which would be a table of worlds, each item being a list of currently connected players. The webadmin handler would read this variable and create the page from it; the plugin would use HOOK_PLAYER_JOINED and HOOK_DISCONNECT to update the variable.</p>
|
||||
|
||||
<h2>What to avoid</h2>
|
||||
<p>
|
||||
Now that we know what the danger is and how to avoid it, how do we know if our code is susceptible?</p>
|
||||
<p>
|
||||
The general rule of thumb is to avoid calling any functions that read or write lists of things in the webserver thread. This means most ForEach() and DoWith() functions. Only <a href="cRoot.html">cRoot</a>:ForEachWorld() is safe - because the list of worlds is not expected to change, so it is not guarded by a mutex. Getting and setting world's blocks is, naturally, unsafe, as is calling other plugins, or creating entities.</p>
|
||||
|
||||
<h2>Example</h2>
|
||||
The Core has the facility to kick players using the web interface. It used the following code for the kicking (inside the webadmin handler):
|
||||
<pre class="prettyprint lang-lua">
|
||||
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)
|
||||
</pre>
|
||||
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:
|
||||
<pre class="prettyprint lang-lua">
|
||||
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
|
||||
)
|
||||
</pre>
|
||||
<script>
|
||||
prettyPrint();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
2
MCServer/Plugins/APIDump/lang-lua.js
Normal file
2
MCServer/Plugins/APIDump/lang-lua.js
Normal file
@ -0,0 +1,2 @@
|
||||
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\S\s]*?(?:]\1]|$)|[^\n\r]*)/],["str",/^\[(=*)\[[\S\s]*?(?:]\1]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],
|
||||
["pln",/^[_a-z]\w*/i],["pun",/^[^\w\t\n\r \xa0][^\w\t\n\r "'+=\xa0-]*/]]),["lua"]);
|
56
MCServer/Plugins/APIDump/main.css
Normal file
56
MCServer/Plugins/APIDump/main.css
Normal file
@ -0,0 +1,56 @@
|
||||
html
|
||||
{
|
||||
background-color: #C0C0C0;
|
||||
}
|
||||
|
||||
table
|
||||
{
|
||||
background-color: #fff;
|
||||
border-spacing: 0px;
|
||||
border-collapse: collapse;
|
||||
border-color: gray;
|
||||
}
|
||||
|
||||
tr
|
||||
{
|
||||
display: table-row;
|
||||
vertical-align: inherit;
|
||||
border-color: inherit;
|
||||
}
|
||||
|
||||
td, th
|
||||
{
|
||||
display: table-cell;
|
||||
vertical-align: inherit;
|
||||
padding: 3px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
pre
|
||||
{
|
||||
border: 1px solid #ccc;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
min-width: 800px;
|
||||
width: 95%;
|
||||
margin: 10px auto;
|
||||
background-color: white;
|
||||
border: 4px #FF8C00 solid;
|
||||
border-radius: 20px;
|
||||
font-family: Calibri, Trebuchet MS;
|
||||
}
|
||||
|
||||
header
|
||||
{
|
||||
text-align: center;
|
||||
font-family: Segoe UI Light, Helvetica;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
padding: 0px 25px 25px 25px;
|
||||
}
|
||||
|
@ -1,193 +0,0 @@
|
||||
|
||||
-- main.lua
|
||||
|
||||
-- Implements the plugin entrypoint (in this case the entire plugin)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Initialize(Plugin)
|
||||
Plugin:SetName("APIDump")
|
||||
Plugin:SetVersion(1)
|
||||
|
||||
PluginManager = cRoot:Get():GetPluginManager()
|
||||
LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
|
||||
|
||||
-- dump all available API functions and objects:
|
||||
DumpAPI();
|
||||
|
||||
-- Dump all available API objects in wiki-style tables:
|
||||
DumpAPIWiki();
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function DumpAPI()
|
||||
LOG("Dumping all available functions to API.txt...");
|
||||
function dump (prefix, a, Output)
|
||||
for i, v in pairs (a) do
|
||||
if (type(v) == "table") then
|
||||
if (GetChar(i, 1) ~= ".") then
|
||||
if (v == _G) then
|
||||
-- LOG(prefix .. i .. " == _G, CYCLE, ignoring");
|
||||
elseif (v == _G.package) then
|
||||
-- LOG(prefix .. i .. " == _G.package, ignoring");
|
||||
else
|
||||
dump(prefix .. i .. ".", v, Output)
|
||||
end
|
||||
end
|
||||
elseif (type(v) == "function") then
|
||||
if (string.sub(i, 1, 2) ~= "__") then
|
||||
table.insert(Output, prefix .. i .. "()");
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local Output = {};
|
||||
dump("", _G, Output);
|
||||
|
||||
table.sort(Output);
|
||||
local f = io.open("API.txt", "w");
|
||||
for i, n in ipairs(Output) do
|
||||
f:write(n, "\n");
|
||||
end
|
||||
f:close();
|
||||
LOG("API.txt written.");
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function DumpAPIWiki()
|
||||
--[[
|
||||
We want an API table of the following shape:
|
||||
local API = {
|
||||
{"cCuboid", {
|
||||
Functions = {
|
||||
"Sort",
|
||||
"IsInside"
|
||||
},
|
||||
Constants = {
|
||||
}
|
||||
}},
|
||||
{"cBlockArea", {
|
||||
Functions = {
|
||||
"Clear",
|
||||
"CopyFrom",
|
||||
...
|
||||
}
|
||||
Constants = {
|
||||
{"baTypes", 0},
|
||||
{"baMetas", 1},
|
||||
...
|
||||
}
|
||||
...
|
||||
}}
|
||||
};
|
||||
local Globals = {
|
||||
Functions = {
|
||||
...
|
||||
},
|
||||
Constants = {
|
||||
...
|
||||
}
|
||||
};
|
||||
--]]
|
||||
|
||||
LOG("Dumping all available functions and constants to API_wiki.txt...");
|
||||
|
||||
local Globals = {Functions = {}, Constants = {}};
|
||||
local API = {};
|
||||
|
||||
local function Add(a_APIContainer, a_ClassName, a_ClassObj)
|
||||
if (type(a_ClassObj) == "function") then
|
||||
table.insert(a_APIContainer.Functions, a_ClassName);
|
||||
elseif (type(a_ClassObj) == "number") then
|
||||
table.insert(a_APIContainer.Constants, {a_ClassName, a_ClassObj});
|
||||
end
|
||||
end
|
||||
|
||||
local function SortClass(a_ClassAPI)
|
||||
-- Sort the function list and constant lists:
|
||||
table.sort(a_ClassAPI.Functions);
|
||||
table.sort(a_ClassAPI.Constants,
|
||||
function(c1, c2)
|
||||
return (c1[1] < c2[1]);
|
||||
end
|
||||
);
|
||||
end;
|
||||
|
||||
local function ParseClass(a_ClassObj)
|
||||
local res = {Functions = {}, Constants = {}};
|
||||
for i, v in pairs(a_ClassObj) do
|
||||
Add(res, i, v);
|
||||
end
|
||||
|
||||
SortClass(res);
|
||||
return res;
|
||||
end
|
||||
|
||||
for i, v in pairs(_G) do
|
||||
if (type(v) == "table") then
|
||||
-- It is a table - probably a class
|
||||
local StartLetter = GetChar(i, 0);
|
||||
if (StartLetter == "c") then
|
||||
-- Starts with a "c", handle it as a MCS API class
|
||||
table.insert(API, {i, ParseClass(v)});
|
||||
end
|
||||
else
|
||||
Add(Globals, i, v);
|
||||
end
|
||||
end
|
||||
SortClass(Globals);
|
||||
table.sort(API,
|
||||
function(c1, c2)
|
||||
return (c1[1] < c2[1]);
|
||||
end
|
||||
);
|
||||
|
||||
-- Now dump the whole thing into a file, formatted as a wiki table:
|
||||
local function WriteClass(a_File, a_ClassAPI)
|
||||
if (#a_ClassAPI.Functions > 0) then
|
||||
a_File:write("Functions:\n");
|
||||
a_File:write("^ Function name ^ Parameters ^ Return value ^ Note ^\n");
|
||||
for i, n in ipairs(a_ClassAPI.Functions) do
|
||||
a_File:write("| " .. n .. " | | | |\n");
|
||||
end
|
||||
a_File:write("\n\n");
|
||||
end
|
||||
|
||||
if (#a_ClassAPI.Constants > 0) then
|
||||
a_File:write("Constants:\n");
|
||||
a_File:write("^ Constant ^ Value ^ Note ^\n");
|
||||
for i, n in ipairs(a_ClassAPI.Constants) do
|
||||
a_File:write("| " .. n[1] .. " | " .. n[2] .. " | |\n");
|
||||
end
|
||||
a_File:write("\n\n");
|
||||
end
|
||||
end
|
||||
|
||||
local f = io.open("API_wiki.txt", "w");
|
||||
for i, n in ipairs(API) do
|
||||
f:write("Class " .. n[1] .. "\n");
|
||||
WriteClass(f, n[2]);
|
||||
f:write("\n\n\n----------------\n");
|
||||
end
|
||||
f:write("globals:\n");
|
||||
WriteClass(f, Globals);
|
||||
f:close();
|
||||
|
||||
LOG("API_wiki.txt file written");
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
1335
MCServer/Plugins/APIDump/main_APIDump.lua
Normal file
1335
MCServer/Plugins/APIDump/main_APIDump.lua
Normal file
File diff suppressed because it is too large
Load Diff
1
MCServer/Plugins/APIDump/prettify.css
Normal file
1
MCServer/Plugins/APIDump/prettify.css
Normal file
@ -0,0 +1 @@
|
||||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
30
MCServer/Plugins/APIDump/prettify.js
Normal file
30
MCServer/Plugins/APIDump/prettify.js
Normal file
@ -0,0 +1,30 @@
|
||||
!function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
|
||||
(function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a=
|
||||
b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a<f;++a){var h=b[a];if(/\\[bdsw]/i.test(h))c.push(h);else{var h=d(h),l;a+2<f&&"-"===b[a+1]?(l=d(b[a+2]),a+=2):l=h;e.push([h,l]);l<65||h>122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;a<e.length;++a)h=e[a],h[0]<=f[1]+1?f[1]=Math.max(f[1],h[1]):b.push(f=h);for(a=0;a<b.length;++a)h=b[a],c.push(g(h[0])),
|
||||
h[1]>h[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f<c;++f){var l=a[f];l==="("?++h:"\\"===l.charAt(0)&&(l=+l.substring(1))&&(l<=h?d[l]=-1:a[f]=g(l))}for(f=1;f<d.length;++f)-1===d[f]&&(d[f]=++x);for(h=f=0;f<c;++f)l=a[f],l==="("?(++h,d[h]||(a[f]="(?:")):"\\"===l.charAt(0)&&(l=+l.substring(1))&&l<=h&&
|
||||
(a[f]="\\"+d[l]);for(f=0;f<c;++f)"^"===a[f]&&"^"!==a[f+1]&&(a[f]="");if(e.ignoreCase&&m)for(f=0;f<c;++f)l=a[f],e=l.charAt(0),l.length>=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k<c;++k){var i=a[k];if(i.ignoreCase)j=!0;else if(/[a-z]/i.test(i.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){m=!0;j=!1;break}}for(var r={b:8,t:9,n:10,v:11,
|
||||
f:12,r:13},n=[],k=0,c=a.length;k<c;++k){i=a[k];if(i.global||i.multiline)throw Error(""+i);n.push("(?:"+s(i)+")")}return RegExp(n.join("|"),j?"gi":"g")}function T(a,d){function g(a){var c=a.nodeType;if(c==1){if(!b.test(a.className)){for(c=a.firstChild;c;c=c.nextSibling)g(c);c=a.nodeName.toLowerCase();if("br"===c||"li"===c)s[j]="\n",m[j<<1]=x++,m[j++<<1|1]=a}}else if(c==3||c==4)c=a.nodeValue,c.length&&(c=d?c.replace(/\r\n?/g,"\n"):c.replace(/[\t\n\r ]+/g," "),s[j]=c,m[j<<1]=x,x+=c.length,m[j++<<1|1]=
|
||||
a)}var b=/(?:^|\s)nocode(?:\s|$)/,s=[],x=0,m=[],j=0;g(a);return{a:s.join("").replace(/\n$/,""),d:m}}function H(a,d,g,b){d&&(a={a:d,e:a},g(a),b.push.apply(b,a.g))}function U(a){for(var d=void 0,g=a.firstChild;g;g=g.nextSibling)var b=g.nodeType,d=b===1?d?a:g:b===3?V.test(g.nodeValue)?a:d:d;return d===a?void 0:d}function C(a,d){function g(a){for(var j=a.e,k=[j,"pln"],c=0,i=a.a.match(s)||[],r={},n=0,e=i.length;n<e;++n){var z=i[n],w=r[z],t=void 0,f;if(typeof w==="string")f=!1;else{var h=b[z.charAt(0)];
|
||||
if(h)t=z.match(h[1]),w=h[0];else{for(f=0;f<x;++f)if(h=d[f],t=z.match(h[1])){w=h[0];break}t||(w="pln")}if((f=w.length>=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c<i;++c){var r=
|
||||
g[c],n=r[3];if(n)for(var e=n.length;--e>=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
|
||||
q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com",
|
||||
/^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+
|
||||
s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,
|
||||
q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d=
|
||||
c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i<c.length;++i)b(c[i]);d===(d|0)&&c[0].setAttribute("value",d);var r=j.createElement("ol");
|
||||
r.className="linenums";for(var d=Math.max(0,d-1|0)||0,i=0,n=c.length;i<n;++i)k=c[i],k.className="L"+(i+d)%10,k.firstChild||k.appendChild(j.createTextNode("\u00a0")),r.appendChild(k);a.appendChild(r)}function p(a,d){for(var g=d.length;--g>=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*</.test(d)?"default-markup":"default-code";return F[a]}function K(a){var d=a.h;try{var g=T(a.c,a.i),b=g.a;
|
||||
a.a=b;a.d=g.d;a.e=0;I(d,b)(a);var s=/\bMSIE\s(\d+)/.exec(navigator.userAgent),s=s&&+s[1]<=8,d=/\n/g,x=a.a,m=x.length,g=0,j=a.d,k=j.length,b=0,c=a.g,i=c.length,r=0;c[i]=m;var n,e;for(e=n=0;e<i;)c[e]!==c[e+2]?(c[n++]=c[e++],c[n++]=c[e++]):e+=2;i=n;for(e=n=0;e<i;){for(var p=c[e],w=c[e+1],t=e+2;t+2<=i&&c[t+1]===w;)t+=2;c[n++]=p;c[n++]=w;e=t}c.length=n;var f=a.c,h;if(f)h=f.style.display,f.style.display="none";try{for(;b<k;){var l=j[b+2]||m,B=c[r+2]||m,t=Math.min(l,B),A=j[b+1],G;if(A.nodeType!==1&&(G=x.substring(g,
|
||||
t))){s&&(G=G.replace(d,"\r"));A.nodeValue=G;var L=A.ownerDocument,o=L.createElement("span");o.className=c[r+1];var v=A.parentNode;v.replaceChild(o,A);o.appendChild(A);g<l&&(j[b+1]=A=L.createTextNode(x.substring(t,l)),v.insertBefore(A,o.nextSibling))}g=t;g>=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
|
||||
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],
|
||||
O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
|
||||
Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,
|
||||
V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",
|
||||
/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);p(C([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],
|
||||
["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);p(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);p(v({keywords:M,hashComments:!0,cStyleComments:!0,types:R}),["c","cc","cpp","cxx","cyc","m"]);p(v({keywords:"null,true,false"}),["json"]);p(v({keywords:O,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:R}),
|
||||
["cs"]);p(v({keywords:N,cStyleComments:!0}),["java"]);p(v({keywords:y,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);p(v({keywords:P,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);p(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);p(v({keywords:Q,
|
||||
hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);p(v({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);p(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);p(v({keywords:W,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]);
|
||||
p(C([],[["str",/^[\S\s]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:C,registerLangHandler:p,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,g){var b=document.createElement("div");b.innerHTML="<pre>"+a+"</pre>";b=b.firstChild;g&&J(b,g,!0);K({h:d,j:g,c:b,i:1});
|
||||
return b.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function g(){for(var b=D.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;i<p.length&&c.now()<b;i++){for(var d=p[i],j=h,k=d;k=k.previousSibling;){var m=k.nodeType,o=(m===7||m===8)&&k.nodeValue;if(o?!/^\??prettify\b/.test(o):m!==3||/\S/.test(k.nodeValue))break;if(o){j={};o.replace(/\b(\w+)=([\w%+\-.:]+)/g,function(a,b,c){j[b]=c});break}}k=d.className;if((j!==h||e.test(k))&&!v.test(k)){m=!1;for(o=d.parentNode;o;o=o.parentNode)if(f.test(o.tagName)&&
|
||||
o.className&&e.test(o.className)){m=!0;break}if(!m){d.className+=" prettyprinted";m=j.lang;if(!m){var m=k.match(n),y;if(!m&&(y=U(d))&&t.test(y.tagName))m=y.className.match(n);m&&(m=m[1])}if(w.test(d.tagName))o=1;else var o=d.currentStyle,u=s.defaultView,o=(o=o?o.whiteSpace:u&&u.getComputedStyle?u.getComputedStyle(d,q).getPropertyValue("white-space"):0)&&"pre"===o.substring(0,3);u=j.linenums;if(!(u=u==="true"||+u))u=(u=k.match(/\blinenums\b(?::(\d+))?/))?u[1]&&u[1].length?+u[1]:!0:!1;u&&J(d,u,o);r=
|
||||
{h:m,c:d,j:u,i:o};K(r)}}}i<p.length?setTimeout(g,250):"function"===typeof a&&a()}for(var b=d||document.body,s=b.ownerDocument||document,b=[b.getElementsByTagName("pre"),b.getElementsByTagName("code"),b.getElementsByTagName("xmp")],p=[],m=0;m<b.length;++m)for(var j=0,k=b[m].length;j<k;++j)p.push(b[m][j]);var b=q,c=Date;c.now||(c={now:function(){return+new Date}});var i=0,r,n=/\blang(?:uage)?-([\w.]+)(?!\S)/,e=/\bprettyprint\b/,v=/\bprettyprinted\b/,w=/pre|xmp/i,t=/^code$/i,f=/^(?:pre|code|xmp)$/i,
|
||||
h={};g()}};typeof define==="function"&&define.amd&&define("google-code-prettify",[],function(){return Y})})();}()
|
@ -6,20 +6,27 @@ 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 = 1
|
||||
Radius = 10
|
||||
|
||||
-- WORLD
|
||||
WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName()
|
||||
WW_instance = cRoot:Get():GetDefaultWorld()
|
||||
WORLDS = {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Initialize(Plugin)
|
||||
PLUGIN = Plugin
|
||||
|
||||
@ -36,39 +43,25 @@ function Initialize(Plugin)
|
||||
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
|
||||
end
|
||||
|
||||
PLUGIN.IniFile = cIniFile("ChunkWorx.ini")
|
||||
if (PLUGIN.IniFile:ReadFile() == false) then
|
||||
PLUGIN.IniFile:HeaderComment("ChunkWorx Save")
|
||||
PLUGIN.IniFile:AddKeyName("Area data")
|
||||
PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX)
|
||||
PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ)
|
||||
PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX)
|
||||
PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ)
|
||||
PLUGIN.IniFile:AddKeyName("Radial data")
|
||||
PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX)
|
||||
PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ)
|
||||
PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius)
|
||||
PLUGIN.IniFile:WriteFile()
|
||||
end
|
||||
|
||||
AreaStartX = PLUGIN.IniFile:GetValueI("Area data", "StartX")
|
||||
AreaStartZ = PLUGIN.IniFile:GetValueI("Area data", "StartZ")
|
||||
AreaEndX = PLUGIN.IniFile:GetValueI("Area data", "EndX")
|
||||
AreaEndZ = PLUGIN.IniFile:GetValueI("Area data", "EndZ")
|
||||
|
||||
RadialX = PLUGIN.IniFile:GetValueI("Radial data", "RadialX")
|
||||
RadialZ = PLUGIN.IniFile:GetValueI("Radial data", "RadialZ")
|
||||
Radius = PLUGIN.IniFile:GetValueI("Radial data", "Radius")
|
||||
-- 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())
|
||||
--LOG("Test1: " .. math.fmod(1.5, 1)) - return fractional part!
|
||||
return true
|
||||
end
|
||||
|
||||
function OnDisable()
|
||||
PLUGIN.IniFile:WriteFile()
|
||||
LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function OnTick( DeltaTime )
|
||||
if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then
|
||||
@ -128,7 +121,7 @@ function OnTick( DeltaTime )
|
||||
end
|
||||
end
|
||||
end
|
||||
WW_instance:SaveAllChunks()
|
||||
WW_instance:QueueSaveAllChunks()
|
||||
WW_instance:UnloadUnusedChunks()
|
||||
end
|
||||
end
|
||||
|
@ -1,11 +1,44 @@
|
||||
|
||||
-- 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
|
||||
@ -69,21 +102,12 @@ function HandleRequest_Generation( Request )
|
||||
AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
|
||||
AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
|
||||
AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
|
||||
|
||||
PLUGIN.IniFile:DeleteValue("Area data", "StartX")
|
||||
PLUGIN.IniFile:DeleteValue("Area data", "StartZ")
|
||||
PLUGIN.IniFile:DeleteValue("Area data", "EndX")
|
||||
PLUGIN.IniFile:DeleteValue("Area data", "EndZ")
|
||||
PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX)
|
||||
PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ)
|
||||
PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX)
|
||||
PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ)
|
||||
SaveSettings();
|
||||
if (OPERATION_CODE == 0) then
|
||||
GENERATION_STATE = 1
|
||||
elseif (OPERATION_CODE == 1) then
|
||||
GENERATION_STATE = 3
|
||||
end
|
||||
PLUGIN.IniFile:WriteFile()
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
@ -93,26 +117,19 @@ function HandleRequest_Generation( Request )
|
||||
and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
|
||||
-- COMMON (Re)gen
|
||||
if( Request.PostParams["StartRadial"]) then
|
||||
RadialX = tonumber(Request.PostParams["FormRadialX"])
|
||||
RadialZ = tonumber(Request.PostParams["FormRadialZ"])
|
||||
Radius = tonumber(Request.PostParams["FormRadius"])
|
||||
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
|
||||
|
||||
PLUGIN.IniFile:DeleteValue("Radial data", "RadialX")
|
||||
PLUGIN.IniFile:DeleteValue("Radial data", "RadialZ")
|
||||
PLUGIN.IniFile:DeleteValue("Radial data", "Radius")
|
||||
PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX)
|
||||
PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ)
|
||||
PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius)
|
||||
SaveSettings()
|
||||
if (OPERATION_CODE == 0) then
|
||||
GENERATION_STATE = 1
|
||||
elseif (OPERATION_CODE == 1) then
|
||||
GENERATION_STATE = 3
|
||||
end
|
||||
PLUGIN.IniFile:WriteFile()
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
@ -214,7 +231,7 @@ function HandleRequest_Generation( Request )
|
||||
Content = Content .. "</form>"
|
||||
|
||||
-- SELECTING RADIAL
|
||||
Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Raduis (0 to any)"
|
||||
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'>"
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit e3a45f34303331be77aceacf2ba53e503ad7284f
|
||||
Subproject commit ede668bc7c310af49ad7354c00d3f11adbae792a
|
@ -26,24 +26,32 @@ function Initialize(Plugin)
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat);
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity);
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick);
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated);
|
||||
|
||||
PluginManager = cRoot:Get():GetPluginManager();
|
||||
PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities");
|
||||
PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities");
|
||||
PluginManager:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool");
|
||||
PluginManager:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "- Opens up a window using plugin API");
|
||||
PluginManager:BindCommand("/gc", "debuggers", HandleGCCmd, "- Activates the Lua garbage collector");
|
||||
PluginManager:BindCommand("/fast", "debuggers", HandleFastCmd, "- Switches between fast and normal movement speed");
|
||||
PluginManager:BindCommand("/dash", "debuggers", HandleDashCmd, "- Switches between fast and normal sprinting speed");
|
||||
PluginManager:BindCommand("/hunger", "debuggers", HandleHungerCmd, "- Lists the current hunger-related variables");
|
||||
PluginManager:BindCommand("/poison", "debuggers", HandlePoisonCmd, "- Sets food-poisoning for 15 seconds");
|
||||
PluginManager:BindCommand("/starve", "debuggers", HandleStarveCmd, "- Sets the food level to zero");
|
||||
PluginManager:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value");
|
||||
PluginManager:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air");
|
||||
PluginManager:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window");
|
||||
PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off");
|
||||
PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player");
|
||||
PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player");
|
||||
PM = cRoot:Get():GetPluginManager();
|
||||
PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities");
|
||||
PM:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities");
|
||||
PM:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool");
|
||||
PM:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "- Opens up a window using plugin API");
|
||||
PM:BindCommand("/gc", "debuggers", HandleGCCmd, "- Activates the Lua garbage collector");
|
||||
PM:BindCommand("/fast", "debuggers", HandleFastCmd, "- Switches between fast and normal movement speed");
|
||||
PM:BindCommand("/dash", "debuggers", HandleDashCmd, "- Switches between fast and normal sprinting speed");
|
||||
PM:BindCommand("/hunger", "debuggers", HandleHungerCmd, "- Lists the current hunger-related variables");
|
||||
PM:BindCommand("/poison", "debuggers", HandlePoisonCmd, "- Sets food-poisoning for 15 seconds");
|
||||
PM:BindCommand("/starve", "debuggers", HandleStarveCmd, "- Sets the food level to zero");
|
||||
PM:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value");
|
||||
PM:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air");
|
||||
PM:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window");
|
||||
PM:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off");
|
||||
PM:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player");
|
||||
PM:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player");
|
||||
PM:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player");
|
||||
PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp");
|
||||
PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk");
|
||||
PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item");
|
||||
PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace");
|
||||
|
||||
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers);
|
||||
|
||||
-- Enable the following line for BlockArea / Generator interface testing:
|
||||
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
|
||||
@ -499,21 +507,6 @@ end
|
||||
|
||||
|
||||
|
||||
function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc)
|
||||
-- Test ChunkDesc / BlockArea interaction
|
||||
local BlockArea = cBlockArea();
|
||||
ChunkDesc:ReadBlockArea(BlockArea, 0, 15, 50, 70, 0, 15);
|
||||
|
||||
-- BlockArea:SaveToSchematicFile("ChunkBlocks_" .. ChunkX .. "_" .. ChunkZ .. ".schematic");
|
||||
|
||||
ChunkDesc:WriteBlockArea(BlockArea, 5, 115, 5);
|
||||
return false;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function OnChat(a_Player, a_Message)
|
||||
return false, "blabla " .. a_Message;
|
||||
end
|
||||
@ -531,6 +524,27 @@ end
|
||||
|
||||
|
||||
|
||||
function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
|
||||
-- Get the topmost block coord:
|
||||
local Height = a_ChunkDesc:GetHeight(0, 0);
|
||||
|
||||
-- Create a sign there:
|
||||
a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0);
|
||||
local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0);
|
||||
if (BlockEntity ~= nil) then
|
||||
LOG("Setting sign lines...");
|
||||
local SignEntity = tolua.cast(BlockEntity, "cSignEntity");
|
||||
SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)");
|
||||
end
|
||||
|
||||
-- Update the heightmap:
|
||||
a_ChunkDesc:SetHeight(0, 0, Height + 1);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Function "round" copied from http://lua-users.org/wiki/SimpleRound
|
||||
function round(num, idp)
|
||||
local mult = 10^(idp or 0)
|
||||
@ -606,7 +620,7 @@ end
|
||||
|
||||
|
||||
function HandleTestWndCmd(a_Split, a_Player)
|
||||
local WindowType = cWindow.Hopper;
|
||||
local WindowType = cWindow.wtHopper;
|
||||
local WindowSizeX = 5;
|
||||
local WindowSizeY = 1;
|
||||
if (#a_Split == 4) then
|
||||
@ -789,7 +803,7 @@ end
|
||||
|
||||
|
||||
function HandleEnchCmd(a_Split, a_Player)
|
||||
local Wnd = cLuaWindow(cWindow.Enchantment, 1, 1, "Ench");
|
||||
local Wnd = cLuaWindow(cWindow.wtEnchantment, 1, 1, "Ench");
|
||||
a_Player:OpenWindow(Wnd);
|
||||
Wnd:SetProperty(0, 10);
|
||||
Wnd:SetProperty(1, 15);
|
||||
@ -839,3 +853,104 @@ end
|
||||
|
||||
|
||||
|
||||
function HandleAddExperience(a_Split, a_Player)
|
||||
a_Player:DeltaExperience(200);
|
||||
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleRemoveXp(a_Split, a_Player)
|
||||
a_Player:SetCurrentExperience(0);
|
||||
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleFill(a_Split, a_Player)
|
||||
local World = a_Player:GetWorld();
|
||||
local ChunkX = a_Player:GetChunkX();
|
||||
local ChunkZ = a_Player:GetChunkZ();
|
||||
World:ForEachBlockEntityInChunk(ChunkX, ChunkZ,
|
||||
function(a_BlockEntity)
|
||||
local BlockType = a_BlockEntity:GetBlockType();
|
||||
if (
|
||||
(BlockType == E_BLOCK_CHEST) or
|
||||
(BlockType == E_BLOCK_DISPENSER) or
|
||||
(BlockType == E_BLOCK_DROPPER) or
|
||||
(BlockType == E_BLOCK_FURNACE) or
|
||||
(BlockType == E_BLOCK_HOPPER)
|
||||
) then
|
||||
-- This block entity has items (inherits from cBlockEntityWithItems), fill it:
|
||||
-- Note that we're not touching lit furnaces, don't wanna mess them up
|
||||
local EntityWithItems = tolua.cast(a_BlockEntity, "cBlockEntityWithItems");
|
||||
local ItemGrid = EntityWithItems:GetContents();
|
||||
local NumSlots = ItemGrid:GetNumSlots();
|
||||
local ItemToSet = cItem(E_ITEM_GOLD_NUGGET);
|
||||
for i = 0, NumSlots - 1 do
|
||||
if (ItemGrid:GetSlot(i):IsEmpty()) then
|
||||
ItemGrid:SetSlot(i, ItemToSet);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
);
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleFurnaceRecipe(a_Split, a_Player)
|
||||
local HeldItem = a_Player:GetEquippedItem();
|
||||
local Out, NumTicks, In = cRoot:GetFurnaceRecipe(HeldItem);
|
||||
if (Out ~= nil) then
|
||||
a_Player:SendMessage(
|
||||
"Furnace turns " .. ItemToFullString(In) ..
|
||||
" to " .. ItemToFullString(Out) ..
|
||||
" in " .. NumTicks .. " ticks (" ..
|
||||
tostring(NumTicks / 20) .. " seconds)."
|
||||
);
|
||||
else
|
||||
a_Player:SendMessage("There is no furnace recipe that would smelt " .. ItemToString(HeldItem));
|
||||
end
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleFurnaceFuel(a_Split, a_Player)
|
||||
local HeldItem = a_Player:GetEquippedItem();
|
||||
local NumTicks = cRoot:GetFurnaceFuelBurnTime(HeldItem);
|
||||
if (NumTicks > 0) then
|
||||
a_Player:SendMessage(
|
||||
ItemToFullString(HeldItem) .. " would power a furnace for " .. NumTicks ..
|
||||
" ticks (" .. tostring(NumTicks / 20) .. " seconds)."
|
||||
);
|
||||
else
|
||||
a_Player:SendMessage(ItemToString(HeldItem) .. " will not power furnaces.");
|
||||
end
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleRequest_Debuggers(a_Request)
|
||||
local FolderContents = cFile:GetFolderContents("./");
|
||||
return "<p>The following objects have been returned by cFile:GetFolderContents():<ul><li>" .. table.concat(FolderContents, "</li><li>") .. "</li></ul></p>";
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
19
MCServer/Plugins/MagicCarpet/coremessaging.lua
Normal file
19
MCServer/Plugins/MagicCarpet/coremessaging.lua
Normal file
@ -0,0 +1,19 @@
|
||||
Core = cPluginManager:Get():GetPlugin("Core")
|
||||
|
||||
function SendMessage(a_Player, a_Message)
|
||||
if (Core ~= nil) then
|
||||
Core:Call("SendMessage", a_Player, a_Message)
|
||||
end
|
||||
end
|
||||
|
||||
function SendMessageSuccess(a_Player, a_Message)
|
||||
if (Core ~= nil) then
|
||||
Core:Call("SendMessageSuccess", a_Player, a_Message)
|
||||
end
|
||||
end
|
||||
|
||||
function SendMessageFailure(a_Player, a_Message)
|
||||
if (Core ~= nil) then
|
||||
Core:Call("SendMessageFailure", a_Player, a_Message)
|
||||
end
|
||||
end
|
@ -1,18 +1,16 @@
|
||||
local PLUGIN = {}
|
||||
local Carpets = {}
|
||||
|
||||
function Initialize( Plugin )
|
||||
PLUGIN = Plugin
|
||||
|
||||
Plugin:SetName( "MagicCarpet" )
|
||||
Plugin:SetVersion( 1 )
|
||||
Plugin:SetVersion( 2 )
|
||||
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_DISCONNECT, OnDisconnect)
|
||||
|
||||
local PluginManager = cPluginManager:Get()
|
||||
PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
|
||||
|
||||
LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
||||
LOG( "Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
||||
return true
|
||||
end
|
||||
|
||||
@ -33,14 +31,15 @@ end
|
||||
|
||||
function HandleCarpetCommand( Split, Player )
|
||||
Carpet = Carpets[ Player ]
|
||||
|
||||
if( Carpet == nil ) then
|
||||
Carpets[ Player ] = cCarpet:new()
|
||||
Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "You're on a magic carpet!" )
|
||||
Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. "Look straight down to descend. Jump to ascend!" )
|
||||
SendMessageSuccess(Player, "You're on a magic carpet!")
|
||||
SendMessage(Player, "Look straight down to descend. Jump to ascend.")
|
||||
else
|
||||
Carpet:remove()
|
||||
Carpets[ Player ] = nil
|
||||
Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "The carpet vanished!" )
|
||||
SendMessageSuccess(Player, "The carpet vanished!")
|
||||
end
|
||||
|
||||
return true
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 3019c7b396221b987cd3f89d422276f764834ffe
|
||||
Subproject commit 70d95481e323874b147e3296a2bd0c35563b0bea
|
49
MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua
Normal file
49
MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
-- TestLuaRocks.lua
|
||||
|
||||
-- This is a mockup plugin that does a quick test of LuaRocks capability in MCServer
|
||||
|
||||
-- "Success" is when the plugin loads, downloads the forum webpage and displays the headers and length and then displays both libs as loaded.
|
||||
-- "Failure" usually manifests as one of the "require" lines failing, although you have the luarock installed.
|
||||
-- Note that the plugin deliberately never fully loads, so that it can be reloaded fast by pressing its Enable button in the webadmin's plugin list.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local log30 = require("30log");
|
||||
local socket = require("socket");
|
||||
local http = require("socket.http");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LOGINFO("Trying to download a webpage...");
|
||||
local body, code, headers = http.request('http://forum.mc-server.org/index.php');
|
||||
LOG("code: " .. tostring(code));
|
||||
LOG("headers: ");
|
||||
for k, v in pairs(headers or {}) do
|
||||
LOG(" " .. k .. ": " .. v);
|
||||
end
|
||||
LOG("body length: " .. string.length(body));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Initialize(a_Plugin)
|
||||
if (socket == nil) then
|
||||
LOG("LuaSocket not found");
|
||||
else
|
||||
LOG("LuaSocket loaded");
|
||||
end
|
||||
if (log30 == nil) then
|
||||
LOG("30log not found");
|
||||
else
|
||||
LOG("30log loaded");
|
||||
end
|
||||
LOGINFO("Preventing plugin load so that it may be requested again from the webadmin.");
|
||||
return false;
|
||||
end
|
@ -1 +1 @@
|
||||
Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e
|
||||
Subproject commit 6527b80a77b3b7f5fac0ef214c1b59ad83e39b20
|
@ -1,18 +1,20 @@
|
||||
/============================\
|
||||
| Custom Minecraft Server |
|
||||
| Created by Kevin Bansberg |
|
||||
| (MCServer) |
|
||||
| |
|
||||
| Founder: Kevin Bansberg |
|
||||
| A.K.A. FakeTruth |
|
||||
| Lead dev: Mattes D |
|
||||
| A.K.A. _Xoft(o) |
|
||||
| A.K.A. xoft |
|
||||
| Monsters by Alex Sonek |
|
||||
| A.K.A. Duralex |
|
||||
| Stuff by Mattes D |
|
||||
| A.K.A. _Xoft(o) |
|
||||
|============================|
|
||||
| Info: WWW.MC-SERVER.ORG |
|
||||
| WWW.AE-C.NET\n") |
|
||||
| WWW.RBTHINKTANK.COM |
|
||||
| Info: www.mc-server.org |
|
||||
| www.ae-c.net |
|
||||
| www.rbthinktank.com |
|
||||
| Mail: faketruth@gmail.com |
|
||||
\============================/
|
||||
|
||||
|
||||
Compatible clients: 1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2
|
||||
Compatible protocol versions: 29, 39, 47, 49, 51, 60, 61, 73, 74
|
||||
Compatible clients: 1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2, 1.6.3, 1.6.4
|
||||
Compatible protocol versions: 29, 39, 47, 49, 51, 60, 61, 73, 74, 77, 78
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# This file describes the crafting recipes that MCServer knows.
|
||||
# The syntax is as follows:
|
||||
# <Line> = <Recipe>#<Comment>
|
||||
@ -96,7 +95,11 @@ BrickStairs, 4 = BrickBlock, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
|
||||
SandstoneStairs, 4 = Sandstone, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
|
||||
SandstoneStairs, 4 = Sandstone, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
|
||||
NetherBrickStairs, 4 = NetherBrick, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
|
||||
NetherBrickStairs, 4 = NetherBrick, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
|
||||
quartzstairs, 4 = QuartzBlock, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
|
||||
quartzstairs, 4 = QuartzBlock, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
|
||||
StoneBrickStairs, 4 = StoneBrick, 1:1, 1:2, 2:2, 1:3, 2:3, 3:3
|
||||
StoneBrickStairs, 4 = StoneBrick, 3:1, 2:2, 3:2, 1:3, 2:3, 3:3
|
||||
SnowBlock = SnowBall, 1:1, 1:2, 2:1, 2:2
|
||||
ClayBlock = Clay, 1:1, 1:2, 2:1, 2:2
|
||||
BrickBlock = Brick, 1:1, 1:2, 2:1, 2:2
|
||||
@ -376,8 +379,45 @@ GreenWool = Wool, * | GreenDye, *
|
||||
RedWool = Wool, * | RedDye, *
|
||||
BlackWool = Wool, * | BlackDye, *
|
||||
|
||||
#******************************************************#
|
||||
# Stained Glass:
|
||||
#
|
||||
WhiteStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BoneMeal, 2:2
|
||||
OrangeStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | OrangeDye, 2:2
|
||||
MagentaStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | MagentaDye, 2:2
|
||||
LightBlueStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | LightBlueDye, 2:2
|
||||
YellowStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | YellowDye, 2:2
|
||||
LimeStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | LimeDye, 2:2
|
||||
PinkStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | PinkDye, 2:2
|
||||
GrayStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | GrayDye, 2:2
|
||||
LightGrayStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | LightGrayDye, 2:2
|
||||
CyanStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | CyanDye, 2:2
|
||||
VioletStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | VioletDye, 2:2
|
||||
BlueStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BlueDye, 2:2
|
||||
BrownStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BrownDye, 2:2
|
||||
GreenStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | GreenDye, 2:2
|
||||
RedStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | RedDye, 2:2
|
||||
BlackStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BlackDye, 2:2
|
||||
|
||||
|
||||
#******************************************************#
|
||||
# Stained Glass Pane:
|
||||
#
|
||||
WhiteStainedGlassPane, 16 = WhiteStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
OrangeStainedGlassPane, 16 = OrangeStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
MagentaStainedGlassPane, 16 = MagentaStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
LightBlueStainedGlassPane, 16 = LightBlueStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
YellowStainedGlassPane, 16 = YellowStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
LimeStainedGlassPane, 16 = LimeStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
PinkStainedGlassPane, 16 = PinkStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
GrayStainedGlassPane, 16 = GrayStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
LightGrayStainedGlassPane, 16 = LightGrayStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
CyanStainedGlassPane, 16 = CyanStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
VioletStainedGlassPane, 16 = VioletStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
BlueStainedGlassPane, 16 = BlueStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
BrownStainedGlassPane, 16 = BrownStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
GreenStainedGlassPane, 16 = GreenStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
RedStainedGlassPane, 16 = RedStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
BlackStainedGlassPane , 16 = BlackStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
|
||||
|
||||
|
||||
#******************************************************#
|
||||
|
@ -13,5 +13,5 @@ Color=2
|
||||
Inherits=Default
|
||||
|
||||
[Default]
|
||||
Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn,transapi.setlang
|
||||
Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn,transapi.setlang,core.tell,core.me
|
||||
Color=7
|
||||
|
@ -117,8 +117,20 @@ darkgreenwool=35:13
|
||||
dkgreenwool=35:13
|
||||
redwool=35:14
|
||||
blackwool=35:15
|
||||
flower=37
|
||||
dandelion=37
|
||||
|
||||
; Renamed in 1.7, use "poppy" instead; kept for compatibility reasons, will be removed later on.
|
||||
rose=38
|
||||
|
||||
flower=38
|
||||
poppy=38
|
||||
blueorchid=38:1
|
||||
allium=38:2
|
||||
redtulip=38:4
|
||||
orangetulip=38:5
|
||||
whitetulip=38:6
|
||||
pinktulip=38:7
|
||||
oxeyedaisy=38:8
|
||||
brownmushroom=39
|
||||
redmushroom=40
|
||||
gold=41
|
||||
@ -208,7 +220,22 @@ portal=90
|
||||
jackolantern=91
|
||||
jacko=91
|
||||
cakeblock=92
|
||||
lockedchest=95
|
||||
whitestainedglass=95
|
||||
orangestainedglass=95:1
|
||||
magentastainedglass=95:2
|
||||
lightbluestainedglass=95:3
|
||||
yellowstainedglass=95:4
|
||||
limestainedglass=95:5
|
||||
pinkstainedglass=95:6
|
||||
graystainedglass=95:7
|
||||
lightgraystainedglass=95:8
|
||||
cyanstainedglass=95:9
|
||||
violetstainedglass=95:10
|
||||
bluestainedglass=95:11
|
||||
brownstainedglass=95:12
|
||||
greenstainedglass=95:13
|
||||
redstainedglass=95:14
|
||||
blackstainedglass=95:15
|
||||
trapdoor=96
|
||||
silverfishblock=97
|
||||
stonebricks=98
|
||||
@ -281,6 +308,42 @@ pillarquartzblock=155:2
|
||||
quartzstairs=156
|
||||
activatorrail=157
|
||||
dropper=158
|
||||
whitestainedclay=159
|
||||
orangestainedclay=159:1
|
||||
magentastainedclay=159:2
|
||||
lightbluestainedclay=159:3
|
||||
yellowstainedclay=159:4
|
||||
limestainedclay=159:5
|
||||
pinkstainedclay=159:6
|
||||
graystainedclay=159:7
|
||||
lightgraystainedclay=159:8
|
||||
cyanstainedclay=159:9
|
||||
violetstainedclay=159:10
|
||||
bluestainedclay=159:11
|
||||
brownstainedclay=159:12
|
||||
greenstainedclay=159:13
|
||||
redstainedclay=159:14
|
||||
blackstainedclay=159:15
|
||||
whitestainedglasspane=160
|
||||
orangestainedglasspane=160:1
|
||||
magentastainedglasspane=160:2
|
||||
lightbluestainedglasspane=160:3
|
||||
yellowstainedglasspane=160:4
|
||||
limestainedglasspane=160:5
|
||||
pinkstainedglasspane=160:6
|
||||
graystainedglasspane=160:7
|
||||
lightgraystainedglasspane=160:8
|
||||
cyanstainedglasspane=160:9
|
||||
violetstainedglasspane=160:10
|
||||
bluestainedglasspane=160:11
|
||||
brownstainedglasspane=160:12
|
||||
greenstainedglasspane=160:13
|
||||
redstainedglasspane=160:14
|
||||
blackstainedglasspane=160:15
|
||||
acaciawood=162
|
||||
darkoakwood=162:1
|
||||
acaciawoodenstairs=163
|
||||
darkoakwoodenstairs=164
|
||||
haybale=170
|
||||
carpet=171
|
||||
ironshovel=256
|
||||
@ -530,7 +593,12 @@ netherbrickitem=405
|
||||
netherquartz=406
|
||||
tntminecart=407
|
||||
hopperminecart=408
|
||||
ironhorsearmor=417
|
||||
goldhorsearmor=418
|
||||
diamondhorsearmor=419
|
||||
lead=420
|
||||
nametag=421
|
||||
commandblockminecart=422
|
||||
|
||||
goldrecord=2256
|
||||
greenrecord=2257
|
||||
|
@ -69,10 +69,10 @@ SightDistance=25.0
|
||||
MaxHealth=20
|
||||
|
||||
[Ghast]
|
||||
AttackRange=5.0
|
||||
AttackRange=50.0
|
||||
AttackRate=1
|
||||
AttackDamage=0.0
|
||||
SightDistance=25.0
|
||||
SightDistance=50.0
|
||||
MaxHealth=10
|
||||
|
||||
[Silverfish]
|
||||
@ -83,10 +83,9 @@ SightDistance=25.0
|
||||
MaxHealth=8
|
||||
|
||||
[Skeleton]
|
||||
AttackRange=5.0
|
||||
AttackRange=15.0
|
||||
AttackRate=1
|
||||
AttackDamage=3.0
|
||||
SightDistance=25.0
|
||||
SightDistance=40.0
|
||||
MaxHealth=20
|
||||
|
||||
[Slime]
|
||||
@ -111,7 +110,7 @@ SightDistance=25.0
|
||||
MaxHealth=20
|
||||
|
||||
[Blaze]
|
||||
AttackRange=5.0
|
||||
AttackRange=15.0
|
||||
AttackRate=1
|
||||
AttackDamage=6.0
|
||||
SightDistance=25.0
|
||||
@ -152,3 +151,33 @@ AttackRate=1
|
||||
AttackDamage=6.0
|
||||
SightDistance=25.0
|
||||
MaxHealth=16
|
||||
|
||||
[Horse]
|
||||
AttackRange=5.0
|
||||
AttackRate=1
|
||||
AttackDamage=6.0
|
||||
SightDistance=25.0
|
||||
MaxHealth=30
|
||||
|
||||
[EnderDragon]
|
||||
AttackRange=5.0
|
||||
AttackRate=1
|
||||
AttackDamage=6.0
|
||||
SightDistance=25.0
|
||||
MaxHealth=200
|
||||
|
||||
[Giant]
|
||||
AttackRange=5.0
|
||||
AttackRate=1
|
||||
AttackDamage=6.0
|
||||
SightDistance=25.0
|
||||
MaxHealth=100
|
||||
|
||||
[IronGolem]
|
||||
AttackRange=5.0
|
||||
AttackRate=1
|
||||
AttackDamage=6.0
|
||||
SightDistance=25.0
|
||||
MaxHealth=100
|
||||
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
; This is the main server configuration
|
||||
; For help, please visit the Wiki page: http://www.mc-server.org/wiki/doku.php?id=configure:settings.ini
|
||||
; Most of these settings can also be set using the webadmin interface, if it is enabled.
|
||||
|
||||
[Server]
|
||||
Port=25565
|
||||
MaxPlayers=100
|
||||
Description=MCServer - in C++
|
||||
DefaultViewDistance=9
|
||||
|
||||
[Worlds]
|
||||
DefaultWorld=world
|
||||
|
||||
[Plugins]
|
||||
; Plugin=Debuggers
|
||||
; Plugin=DiamondMover
|
||||
; Plugin=HookNotify
|
||||
Plugin=Core
|
||||
Plugin=ChunkWorx
|
||||
Plugin=ChatLog
|
||||
Plugin=TransAPI
|
||||
|
||||
[Monsters]
|
||||
AnimalsOn=0
|
||||
AnimalSpawnInterval=10
|
||||
Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie
|
||||
|
||||
[Authentication]
|
||||
Server=session.minecraft.net
|
||||
Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%
|
||||
Authenticate=0
|
||||
|
7
MCServer/vg
Normal file
7
MCServer/vg
Normal file
@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
# This script runs MCServer under valgrind
|
||||
# It expects valgrind to be normally installed and available
|
||||
# Note that this is for Linux only and debug-only, since it slows down MCS way too much
|
||||
|
||||
valgrind --log-file=valgrind.log --suppressions=vg.supp --tool=memcheck --leak-check=full --leak-resolution=high --show-reachable=yes --track-origins=yes -v ./MCServer
|
0
MCServer/vg.supp
Normal file
0
MCServer/vg.supp
Normal file
@ -1,6 +0,0 @@
|
||||
[WebAdmin]
|
||||
Enabled=1
|
||||
Port=8081
|
||||
|
||||
[User:admin]
|
||||
Password=admin
|
@ -58,7 +58,7 @@ function ShowPage(WebAdmin, TemplateRequest)
|
||||
SiteContent = {}
|
||||
local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path)
|
||||
local Title = "MCServer"
|
||||
local MemoryUsage = cWebAdmin:GetMemoryUsage()
|
||||
local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage()
|
||||
local NumChunks = cRoot:Get():GetTotalChunkCount()
|
||||
local PluginPage = WebAdmin:GetPage(TemplateRequest.Request)
|
||||
local PageContent = PluginPage.Content
|
||||
@ -456,7 +456,7 @@ function ShowPage(WebAdmin, TemplateRequest)
|
||||
</div>
|
||||
<!-- // #containerHolder -->
|
||||
|
||||
<p id="footer">MCServer is using: ]] .. MemoryUsage .. [[MB of memory; Current chunk count: ]] .. NumChunks .. [[ </p>
|
||||
<p id="footer">MCServer is using: ]] .. MemoryUsageKiB / 1024 .. [[ MiB of memory; Current chunk count: ]] .. NumChunks .. [[ </p>
|
||||
</div>
|
||||
<!-- // #wrapper -->
|
||||
</body>
|
||||
|
65
MakeLuaAPI.cmd
Normal file
65
MakeLuaAPI.cmd
Normal file
@ -0,0 +1,65 @@
|
||||
@echo off
|
||||
:: MakeLuaAPI.cmd
|
||||
:: This script is run after the nightbuild to produce the Lua API documentation and upload it to a website.
|
||||
:: It expects at least three environment variables set: ftpsite, ftpuser and ftppass, specifying the FTP site and login to use for the upload
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:: Check that we got all the environment vars needed for the upload:
|
||||
|
||||
if "a%ftppass%" == "a" (
|
||||
echo You need to set FTP password in the ftppass environment variable to upload the files
|
||||
goto end
|
||||
)
|
||||
if "a%ftpuser%" == "a" (
|
||||
echo You need to set FTP username in the ftpuser environment variable to upload the files
|
||||
goto end
|
||||
)
|
||||
if "a%ftpsite%" == "a" (
|
||||
echo You need to set FTP server in the ftpsite environment variable to upload the files
|
||||
goto end
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:: Create the API documentation by running the server and stopping it right after it starts:
|
||||
|
||||
cd MCServer
|
||||
echo stop | MCServer
|
||||
cd ..
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:: Upload the API to the web:
|
||||
|
||||
ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% /LuaAPI MCServer/API/*.*
|
||||
if errorlevel 1 goto haderror
|
||||
echo Upload finished.
|
||||
|
||||
goto end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:haderror
|
||||
echo an error was encountered, check command output above
|
||||
pause
|
||||
goto finished
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:end
|
||||
if "a%1" == "a" pause
|
||||
|
||||
|
||||
|
||||
:finished
|
@ -45,9 +45,9 @@ echo Performing nightbuild of MC-Server
|
||||
set DONOTPAUSE=y
|
||||
|
||||
:: Update the sources to the latest revision:
|
||||
del source\Bindings.cpp
|
||||
del source\Bindings.h
|
||||
git checkout -- source\Bindings.*
|
||||
del src\Bindings.cpp
|
||||
del src\Bindings.h
|
||||
git checkout -- src\Bindings.*
|
||||
git pull
|
||||
if errorlevel 1 goto haderror
|
||||
|
||||
@ -78,11 +78,11 @@ if exist %TAGFILE% (
|
||||
|
||||
|
||||
:: Update the Bindings:
|
||||
del source\Bindings.cpp
|
||||
del source\Bindings.h
|
||||
del src\Bindings.cpp
|
||||
del src\Bindings.h
|
||||
echo Updating Lua bindings
|
||||
set ALLTOLUA_WAIT=N
|
||||
cd source
|
||||
cd src
|
||||
call AllToLua.bat
|
||||
cd ..
|
||||
|
||||
|
@ -10,7 +10,7 @@ Installation
|
||||
|
||||
To install MCServer, you can either download the repository and compile it, or download a pre-compiled version.
|
||||
|
||||
If you are cloning the repository, you are required to recursively download the submodules also with `git clone -r`. When pulling, you should use `git pull --recurse-submodules`. You might want to set the base forms as aliases to these.
|
||||
After you've cloned the repository, you probably want to pull down the submodules (core plugins, some dependencies). This can be achieved with `git submodule init` and then on a regular basis (to keep up to date) `git submodule update`.
|
||||
|
||||
Compilation instructions are available in the COMPILING file.
|
||||
|
||||
@ -27,3 +27,5 @@ Other Stuff
|
||||
-----------
|
||||
|
||||
For other stuff, including plugins and discussion, check the [forums](http://forum.mc-server.org) and [wiki](http://mc-server.org/wiki/).
|
||||
|
||||
Earn bitcoins for commits or donate to reward the MCServer developers: [![tip for next commit](http://tip4commit.com/projects/74.svg)](http://tip4commit.com/projects/74)
|
||||
|
@ -41,7 +41,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""..\..\zlib-1.2.7""
|
||||
AdditionalIncludeDirectories=""..\..\lib""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -118,7 +118,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories=""..\..\zlib-1.2.7""
|
||||
AdditionalIncludeDirectories=""..\..\lib""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
@ -196,7 +196,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories=""..\..\zlib-1.2.7""
|
||||
AdditionalIncludeDirectories=""..\..\lib""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
@ -374,27 +374,27 @@
|
||||
Name="shared"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
|
||||
RelativePath="..\..\src\OSSupport\CriticalSection.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\CriticalSection.h"
|
||||
RelativePath="..\..\src\OSSupport\CriticalSection.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\Endianness.h"
|
||||
RelativePath="..\..\src\Endianness.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\Event.cpp"
|
||||
RelativePath="..\..\src\OSSupport\Event.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\Event.h"
|
||||
RelativePath="..\..\src\OSSupport\Event.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\WorldStorage\FastNBT.cpp"
|
||||
RelativePath="..\..\src\WorldStorage\FastNBT.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
@ -422,39 +422,39 @@
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\WorldStorage\FastNBT.h"
|
||||
RelativePath="..\..\src\WorldStorage\FastNBT.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\File.cpp"
|
||||
RelativePath="..\..\src\OSSupport\File.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\File.h"
|
||||
RelativePath="..\..\src\OSSupport\File.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\GZipFile.cpp"
|
||||
RelativePath="..\..\src\OSSupport\GZipFile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\GZipFile.h"
|
||||
RelativePath="..\..\src\OSSupport\GZipFile.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\IsThread.cpp"
|
||||
RelativePath="..\..\src\OSSupport\IsThread.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\OSSupport\IsThread.h"
|
||||
RelativePath="..\..\src\OSSupport\IsThread.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\StringUtils.cpp"
|
||||
RelativePath="..\..\src\StringUtils.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\StringUtils.h"
|
||||
RelativePath="..\..\src\StringUtils.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "ChunkExtract.h"
|
||||
#include "../../source/OSSupport/GZipFile.h"
|
||||
#include "../../src/OSSupport/GZipFile.h"
|
||||
|
||||
|
||||
|
||||
|
@ -138,6 +138,7 @@ typedef unsigned short UInt16;
|
||||
|
||||
|
||||
// CRT stuff:
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
@ -162,12 +163,12 @@ typedef unsigned short UInt16;
|
||||
|
||||
|
||||
// Common headers (part 1, without macros):
|
||||
#include "../../source/StringUtils.h"
|
||||
#include "../../source/OSSupport/CriticalSection.h"
|
||||
#include "../../source/OSSupport/Semaphore.h"
|
||||
#include "../../source/OSSupport/Event.h"
|
||||
#include "../../source/OSSupport/IsThread.h"
|
||||
#include "../../source/OSSupport/File.h"
|
||||
#include "../../src/StringUtils.h"
|
||||
#include "../../src/OSSupport/CriticalSection.h"
|
||||
#include "../../src/OSSupport/Semaphore.h"
|
||||
#include "../../src/OSSupport/Event.h"
|
||||
#include "../../src/OSSupport/IsThread.h"
|
||||
#include "../../src/OSSupport/File.h"
|
||||
|
||||
|
||||
|
||||
@ -220,8 +221,8 @@ public:
|
||||
|
||||
|
||||
// Common headers (part 2, with macros):
|
||||
#include "../../source/ChunkDef.h"
|
||||
#include "../../source/BlockID.h"
|
||||
#include "../../src/ChunkDef.h"
|
||||
#include "../../src/BlockID.h"
|
||||
|
||||
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include "Globals.h"
|
||||
#include "Processor.h"
|
||||
#include "Callback.h"
|
||||
#include "../../source/WorldStorage/FastNBT.h"
|
||||
#include "zlib.h"
|
||||
#include "../../src/WorldStorage/FastNBT.h"
|
||||
#include "zlib/zlib.h"
|
||||
#include "Utils.h"
|
||||
|
||||
|
||||
@ -554,8 +554,8 @@ void cProcessor::PopulateFileQueue(const AString & a_WorldFolder)
|
||||
{
|
||||
Path.push_back(cFile::PathSeparator);
|
||||
}
|
||||
AStringList AllFiles = GetDirectoryContents(Path.c_str());
|
||||
for (AStringList::iterator itr = AllFiles.begin(), end = AllFiles.end(); itr != end; ++itr)
|
||||
AStringVector AllFiles = cFile::GetFolderContents(Path.c_str());
|
||||
for (AStringVector::iterator itr = AllFiles.begin(), end = AllFiles.end(); itr != end; ++itr)
|
||||
{
|
||||
if (itr->rfind(".mca") != itr->length() - 4)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Statistics.h"
|
||||
#include "../../source/WorldStorage/FastNBT.h"
|
||||
#include "../../src/WorldStorage/FastNBT.h"
|
||||
|
||||
|
||||
|
||||
|
3
Tools/BiomeVisualiser/.gitignore
vendored
Normal file
3
Tools/BiomeVisualiser/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
Debug/
|
||||
logs/
|
||||
Release/
|
@ -258,6 +258,11 @@ void cBiomeCache::FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChu
|
||||
|
||||
void cBiomeCache::thrProcessQueueItem(void)
|
||||
{
|
||||
if (m_Source == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cItem * Item = NULL;
|
||||
{
|
||||
cCSLock Lock(m_CS);
|
||||
|
@ -17,7 +17,7 @@ While the area is being filled, requests for biomes may already come, such reque
|
||||
|
||||
|
||||
#include "BiomeSource.h"
|
||||
#include "../source/OSSupport/IsThread.h"
|
||||
#include "../src/OSSupport/IsThread.h"
|
||||
|
||||
|
||||
|
||||
|
114
Tools/BiomeVisualiser/BiomeColors.cpp
Normal file
114
Tools/BiomeVisualiser/BiomeColors.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
// BiomeColors.cpp
|
||||
|
||||
// Implements the g_BiomeColors[] array preparation based on a stored biome-to-color map
|
||||
|
||||
#include "Globals.h"
|
||||
#include "BiomeColors.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int g_BiomeColors[256];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static struct
|
||||
{
|
||||
EMCSBiome Biome;
|
||||
int Color;
|
||||
} g_BiomeColorMap[] =
|
||||
{
|
||||
{ biOcean, 0x000070 },
|
||||
{ biPlains, 0x8db360 },
|
||||
{ biDesert, 0xfa9418 },
|
||||
{ biExtremeHills, 0x606060 },
|
||||
{ biForest, 0x056621 },
|
||||
{ biTaiga, 0x0b6659 },
|
||||
{ biSwampland, 0x2fffda },
|
||||
{ biRiver, 0x3030af },
|
||||
{ biHell, 0x7f0000 },
|
||||
{ biSky, 0x007fff },
|
||||
{ biFrozenOcean, 0xa0a0df },
|
||||
{ biFrozenRiver, 0xa0a0ff },
|
||||
{ biIcePlains, 0xffffff },
|
||||
{ biIceMountains, 0xa0a0a0 },
|
||||
{ biMushroomIsland, 0xff00ff },
|
||||
{ biMushroomShore, 0xa000ff },
|
||||
{ biBeach, 0xfade55 },
|
||||
{ biDesertHills, 0xd25f12 },
|
||||
{ biForestHills, 0x22551c },
|
||||
{ biTaigaHills, 0x163933 },
|
||||
{ biExtremeHillsEdge, 0x7f8f7f },
|
||||
{ biJungle, 0x537b09 },
|
||||
{ biJungleHills, 0x2c4205 },
|
||||
|
||||
{ biJungleEdge, 0x628b17 },
|
||||
{ biDeepOcean, 0x000030 },
|
||||
{ biStoneBeach, 0xa2a284 },
|
||||
{ biColdBeach, 0xfaf0c0 },
|
||||
{ biBirchForest, 0x307444 },
|
||||
{ biBirchForestHills, 0x1f5f32 },
|
||||
{ biRoofedForest, 0x40511a },
|
||||
{ biColdTaiga, 0x31554a },
|
||||
{ biColdTaigaHills, 0x597d72 },
|
||||
{ biMegaTaiga, 0x596651 },
|
||||
{ biMegaTaigaHills, 0x596659 },
|
||||
{ biExtremeHillsPlus, 0x507050 },
|
||||
{ biSavanna, 0xbdb25f },
|
||||
{ biSavannaPlateau, 0xa79d64 },
|
||||
{ biMesa, 0xd94515 },
|
||||
{ biMesaPlateauF, 0xb09765 },
|
||||
{ biMesaPlateau, 0xca8c65 },
|
||||
|
||||
// M variants:
|
||||
{ biSunflowerPlains, 0xb5db88 },
|
||||
{ biDesertM, 0xffbc40 },
|
||||
{ biExtremeHillsM, 0x888888 },
|
||||
{ biFlowerForest, 0x2d8e49 },
|
||||
{ biTaigaM, 0x338e81 },
|
||||
{ biSwamplandM, 0x07f9b2 },
|
||||
{ biIcePlainsSpikes, 0xb4dcdc },
|
||||
{ biJungleM, 0x7ba331 },
|
||||
{ biJungleEdgeM, 0x628b17 },
|
||||
{ biBirchForestM, 0x589c6c },
|
||||
{ biBirchForestHillsM, 0x47875a },
|
||||
{ biRoofedForestM, 0x687942 },
|
||||
{ biColdTaigaM, 0x243f36 },
|
||||
{ biMegaSpruceTaiga, 0x454f3e },
|
||||
{ biMegaSpruceTaigaHills, 0x454f4e },
|
||||
{ biExtremeHillsPlusM, 0x789878 },
|
||||
{ biSavannaM, 0xe5da87 },
|
||||
{ biSavannaPlateauM, 0xa79d74 },
|
||||
{ biMesaBryce, 0xff6d3d },
|
||||
{ biMesaPlateauFM, 0xd8bf8d },
|
||||
{ biMesaPlateauM, 0xf2b48d },
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static class cBiomeColorsInitializer
|
||||
{
|
||||
public:
|
||||
cBiomeColorsInitializer(void)
|
||||
{
|
||||
// Reset all colors to gray:
|
||||
for (size_t i = 0; i < ARRAYCOUNT(g_BiomeColors); i++)
|
||||
{
|
||||
g_BiomeColors[i] = 0x7f7f7f;
|
||||
}
|
||||
for (size_t i = 0; i < ARRAYCOUNT(g_BiomeColorMap); i++)
|
||||
{
|
||||
g_BiomeColors[g_BiomeColorMap[i].Biome] = g_BiomeColorMap[i].Color;
|
||||
}
|
||||
}
|
||||
} g_Initializer;
|
||||
|
||||
|
||||
|
||||
|
15
Tools/BiomeVisualiser/BiomeColors.h
Normal file
15
Tools/BiomeVisualiser/BiomeColors.h
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
// BiomeColors.h
|
||||
|
||||
// Declares the g_BiomeColors[] array used for biome color lookup
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern int g_BiomeColors[256];
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "BiomeRenderer.h"
|
||||
#include "Pixmap.h"
|
||||
#include "Timer.h"
|
||||
#include "BiomeColors.h"
|
||||
|
||||
|
||||
|
||||
@ -96,40 +97,11 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
|
||||
|
||||
int cBiomeRenderer::GetBiomeColor(EMCSBiome a_Biome)
|
||||
{
|
||||
if ((a_Biome < 0) || (a_Biome > biMaxBiome))
|
||||
if ((a_Biome < 0) || (a_Biome >= ARRAYCOUNT(g_BiomeColors)))
|
||||
{
|
||||
return 0xcfcfcf; // LtGray for unknown biomes
|
||||
return 0xff0000;
|
||||
}
|
||||
|
||||
static int BiomeColor[] =
|
||||
{
|
||||
// RGB:
|
||||
0x0000ff, /* Ocean */
|
||||
0x00cf3f, /* Plains */
|
||||
0xffff00, /* Desert */
|
||||
0x7f7f7f, /* Extreme Hills */
|
||||
0x00cf00, /* Forest */
|
||||
0x007f3f, /* Taiga */
|
||||
0x3f7f00, /* Swampland */
|
||||
0x003fff, /* River */
|
||||
0x7f0000, /* Hell */
|
||||
0x007fff, /* Sky */
|
||||
0x3f3fff, /* Frozen Ocean */
|
||||
0x3f3fff, /* Frozen River */
|
||||
0x7fffcf, /* Ice Plains */
|
||||
0x3fcf7f, /* Ice Mountains */
|
||||
0xcf00cf, /* Mushroom Island */
|
||||
0x7f00ff, /* Mushroom Island Shore */
|
||||
0xffff3f, /* Beach */
|
||||
0xcfcf00, /* Desert Hills */
|
||||
0x00cf3f, /* Forest Hills */
|
||||
0x006f1f, /* Taiga Hills */
|
||||
0x7f8f7f, /* Extreme Hills Edge */
|
||||
0x004f00, /* Jungle */
|
||||
0x003f00, /* Jungle Hills */
|
||||
} ;
|
||||
|
||||
return BiomeColor[a_Biome];
|
||||
return g_BiomeColors[a_Biome];
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user