ProtectinoAreas: Configuratino is now loaded from an INI file
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1576 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
2adf62e22e
commit
e3713be451
@ -8,13 +8,35 @@
|
|||||||
|
|
||||||
|
|
||||||
cConfig = {
|
cConfig = {
|
||||||
m_Wand = cItem(E_ITEM_STICK, 1, 1); -- TODO: Make this configurable by loading it from an INI file
|
m_Wand = cItem(E_ITEM_STICK, 1, 1); -- The item to be used as the selection wand
|
||||||
|
m_AllowInteractNoArea = true; -- If there's no area, is a player allowed to build / dig?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Initializes the cConfig object, loads the configuration from an INI file
|
||||||
|
function InitializeConfig()
|
||||||
|
local ini = cIniFile("ProtectionAreas.ini");
|
||||||
|
if (not(ini:ReadFile())) then
|
||||||
|
LOGINFO(PluginPrefix .. "Cannot read ProtectionAreas.ini, all plugin configuration is set to defaults");
|
||||||
|
end
|
||||||
|
local WandItem = cItem();
|
||||||
|
if (
|
||||||
|
StringToItem(ini:GetValueSet("ProtectionAreas", "WandItem", ItemToString(cConfig.m_Wand)), WandItem) and
|
||||||
|
IsValidItem(WandItem.m_ItemType)
|
||||||
|
) then
|
||||||
|
cConfig.m_Wand = WandItem;
|
||||||
|
end
|
||||||
|
cConfig.m_AllowInteractNoArea = ini:GetValueSetB("ProtectionAreas", "AllowInteractNoArea", cConfig.m_AllowInteractNoArea);
|
||||||
|
ini:WriteFile();
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns true if a_Item is the wand tool item
|
--- Returns true if a_Item is the wand tool item
|
||||||
function cConfig:IsWand(a_Item)
|
function cConfig:IsWand(a_Item)
|
||||||
return (
|
return (
|
||||||
|
@ -23,7 +23,6 @@ end
|
|||||||
--- Called by MCS when a player's connectino is lost - either they disconnected or timed out
|
--- Called by MCS when a player's connectino is lost - either they disconnected or timed out
|
||||||
function OnDisconnect(a_Player, a_Reason)
|
function OnDisconnect(a_Player, a_Reason)
|
||||||
-- Remove the player's cProtectionArea object
|
-- Remove the player's cProtectionArea object
|
||||||
-- TODO: What if there are two players with the same name? need to check
|
|
||||||
g_PlayerAreas[a_Player:GetUniqueID()] = nil;
|
g_PlayerAreas[a_Player:GetUniqueID()] = nil;
|
||||||
|
|
||||||
-- If the player is a VIP, they had a command state, remove that as well
|
-- If the player is a VIP, they had a command state, remove that as well
|
||||||
|
@ -73,8 +73,7 @@ function cPlayerAreas:CanInteractWithBlock(a_BlockX, a_BlockZ)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- The coords are not inside any area
|
-- The coords are not inside any area
|
||||||
-- TODO: Have a config saying whether a player can build in the non-areated space or not
|
return cConfig.m_AllowInteractNoArea;
|
||||||
return true;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ function Initialize(a_Plugin)
|
|||||||
a_Plugin:SetName("ProtectionAreas");
|
a_Plugin:SetName("ProtectionAreas");
|
||||||
a_Plugin:SetVersion(1);
|
a_Plugin:SetVersion(1);
|
||||||
|
|
||||||
|
InitializeConfig();
|
||||||
if (not(InitializeStorage())) then
|
if (not(InitializeStorage())) then
|
||||||
LOGWARNING(PluginPrefix .. "failed to initialize Storage, plugin is disabled");
|
LOGWARNING(PluginPrefix .. "failed to initialize Storage, plugin is disabled");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user