summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/TransAPI/main.lua
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-18 01:36:51 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-18 01:36:51 +0200
commit7014979bffdc08187c8b91c8aefcb0a862a85187 (patch)
treefd22d73a2485bda09caac3d948f752bca7e380c3 /MCServer/Plugins/TransAPI/main.lua
parentBugfix Update [SEE DESC} (diff)
parentFixed LuaWindow destructor causing a crash. (diff)
downloadcuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.gz
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.bz2
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.lz
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.xz
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.zst
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.zip
Diffstat (limited to 'MCServer/Plugins/TransAPI/main.lua')
m---------MCServer/Plugins/TransAPI6
-rw-r--r--MCServer/Plugins/TransAPI/main.lua91
2 files changed, 6 insertions, 91 deletions
diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI
new file mode 160000
+Subproject 52e1de4332a026e58fda843aae98c1f51e57199
diff --git a/MCServer/Plugins/TransAPI/main.lua b/MCServer/Plugins/TransAPI/main.lua
deleted file mode 100644
index 2b6f77da6..000000000
--- a/MCServer/Plugins/TransAPI/main.lua
+++ /dev/null
@@ -1,91 +0,0 @@
--- This plugin copyright Alexander Harkness 2013, licensed under the MIT license.
-
--- Configuration
-g_ServerLang = "en"
-g_ConsoleLang = "en"
-
--- Global Variables
-g_Plugin = nil
-g_PluginManager = nil
-g_PluginDir = nil
-g_UserData = nil
-
--- START WITH DA AWESOME!
-function Initialize( Plugin )
-
- -- Set up the globals.
- g_Plugin = Plugin
- g_PluginManager = cRoot:Get():GetPluginManager()
- g_PluginDir = Plugin:GetDirectory()
-
- -- Set up the plugin details.
- Plugin:SetName( "TransAPI" )
- Plugin:SetVersion( 1 )
-
- -- This is the place for commands!
- g_PluginManager:BindCommand("/language", "transapi.setlang", HandleLanguageCommand, " - Set your preferred language (use ISO 639-1)")
-
- -- Load the userdata file.
- g_UserData = cIniFile( g_PluginDir .. "/userdata.ini" )
- if g_UserData ~= true then
- LOGERROR( "TransAPI INI file could not be opened!" )
- end
-
- LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
-
- return true
-
-end
-
-function GetLanguage( Player )
-
- -- Returns a language to use.
- if g_UserData:ReadFile() == true then
- local userLang = g_UserData:GetValueSet( Player:GetName(), "language", "false" )
- g_UserData:WriteFile()
- end
-
- if userLang == "false" then
- return g_ServerLang
- else
- return userLang
- end
-
-end
-
-function GetConsoleLanguage()
- -- Return the language to use for console messages.
- return g_ConsoleLang
-end
-
-function HandleLanguageCommand ( Split, Player )
-
- -- If the user is not setting the language, tell them the currently selected one.
- if #Split ~= 2 then
-
- local userLang = g_UserData:GetValueSet( Player:GetName(), "language", "false" )
- if userLang == "false" then
- return g_ServerLang
- else
- return userLang
- end
-
- end
-
- -- Set the language.
- local success = g_UserData:SetValue( Player:GetName(), "language" Split[2] )
- g_UserData:WriteFile()
-
- if not success then
- Player:SendMessage( "Language could not be set!" )
- else
- Player:SendMessage( "Language set!" )
- end
-
- return true
-
-end
-
-function OnDisable()
- LOG( "Disabled TransAPI!" )
-end