Remove backsticks, for future PostgreSQL support
This commit is contained in:
parent
e9ca904706
commit
2fc5654de1
0
LanguageCN_Simplified.yml
Normal file → Executable file
0
LanguageCN_Simplified.yml
Normal file → Executable file
0
LanguageDA.yml
Normal file → Executable file
0
LanguageDA.yml
Normal file → Executable file
0
LanguageEN.yml
Normal file → Executable file
0
LanguageEN.yml
Normal file → Executable file
0
LanguageES.yml
Normal file → Executable file
0
LanguageES.yml
Normal file → Executable file
0
LanguageLT.yml
Normal file → Executable file
0
LanguageLT.yml
Normal file → Executable file
0
LanguagePT.yml
Normal file → Executable file
0
LanguagePT.yml
Normal file → Executable file
0
LanguageRU.yml
Normal file → Executable file
0
LanguageRU.yml
Normal file → Executable file
167
code/!lang.sk
167
code/!lang.sk
@ -1,26 +1,26 @@
|
|||||||
#structure of table `languages`
|
#structure of table languages
|
||||||
#`EN` = VARCHAR(333)
|
#EN = VARCHAR(333)
|
||||||
#`RU` = VARCHAR(333)
|
#RU = VARCHAR(333)
|
||||||
#... and so on (for each language)
|
#... and so on (for each language)
|
||||||
function YAMLtoSQL():
|
function YAMLtoSQL():
|
||||||
loop {languageslist::*}:
|
loop {languageslist::*}:
|
||||||
load yaml "plugins/Skript/scripts/languages/Language%loop-value in lowercase%.yml" as "lang%loop-value in lowercase%"
|
load yaml "plugins/Skript/scripts/languages/Language%loop-value in lowercase%.yml" as "lang%loop-value in lowercase%"
|
||||||
execute "TRUNCATE TABLE `languages`" in {-sql}
|
execute "TRUNCATE TABLE languages" in {-sql}
|
||||||
send last sql error to console if last sql error is set
|
send last sql error to console if last sql error is set
|
||||||
wait a tick
|
wait a tick
|
||||||
loop yaml nodes from "langen":
|
loop yaml nodes from "langen":
|
||||||
loop {languageslist::*}:
|
loop {languageslist::*}:
|
||||||
set {_list::%loop-value-2%} to yaml value loop-value-1 from "lang%loop-value-2 in lowercase%"
|
set {_list::%loop-value-2%} to yaml value loop-value-1 from "lang%loop-value-2 in lowercase%"
|
||||||
execute "INSERT INTO `languages` VALUES (%{_list::en}%, %{_list::lt}%, %{_list::ru}%, %{_list::es}%, %{_list::da}%, %{_list::pt}%, %{_list::CN_Simplified}%)" in {-sql}
|
execute "INSERT INTO languages VALUES (%{_list::en}%, %{_list::lt}%, %{_list::ru}%, %{_list::es}%, %{_list::da}%, %{_list::pt}%, %{_list::CN_Simplified}%)" in {-sql}
|
||||||
if last sql error is set:
|
if last sql error is set:
|
||||||
send last sql error to console and ops if last sql error is set
|
send last sql error to console and ops if last sql error is set
|
||||||
send "Error happened on %{_list::en}%" to console and ops
|
send "Error happened on %{_list::en}%" to console and ops
|
||||||
#load languages from mysql
|
#load languages from mysql
|
||||||
function loadSQLLanguages():
|
function loadSQLLanguages():
|
||||||
execute "SELECT * FROM `languages`" in {-sql} and store the result in {_l::*}
|
execute "SELECT * FROM languages" in {-sql} and store the result in {_l::*}
|
||||||
loop indexes of {_l::*}:
|
loop indexes of {_l::*}:
|
||||||
set {_list::%loop-value%} to loop-value
|
set {_list::%loop-value%} to loop-value
|
||||||
|
|
||||||
#done to make it the first index
|
#done to make it the first index
|
||||||
set {_list::1} to "en"
|
set {_list::1} to "en"
|
||||||
delete {_list::en}
|
delete {_list::en}
|
||||||
@ -36,13 +36,13 @@ on script load:
|
|||||||
wait a tick
|
wait a tick
|
||||||
loadSQLLanguages()
|
loadSQLLanguages()
|
||||||
function SQLtoYAML():
|
function SQLtoYAML():
|
||||||
execute "SELECT * FROM `languages`" in {-sql} and store the result in {_l::*}
|
execute "SELECT * FROM languages" in {-sql} and store the result in {_l::*}
|
||||||
send last sql error to console if last sql error is set
|
send last sql error to console if last sql error is set
|
||||||
loop indexes of {_l::*}:
|
loop indexes of {_l::*}:
|
||||||
unload yaml "lang%loop-value%"
|
unload yaml "lang%loop-value%"
|
||||||
load yaml "plugins/Skript/scripts/languages/Language%loop-value%.yml" as "lang%loop-value%"
|
load yaml "plugins/Skript/scripts/languages/Language%loop-value%.yml" as "lang%loop-value%"
|
||||||
set {_list::%loop-value%} to loop-value
|
set {_list::%loop-value%} to loop-value
|
||||||
|
|
||||||
#done to make it the first index
|
#done to make it the first index
|
||||||
#TODO make it sorted on unedited vs edited, so unedited shows first
|
#TODO make it sorted on unedited vs edited, so unedited shows first
|
||||||
set {_list::1} to "en"
|
set {_list::1} to "en"
|
||||||
@ -68,19 +68,19 @@ expression:
|
|||||||
else:
|
else:
|
||||||
return translate(expression 1, expression 2, expressions 3)
|
return translate(expression 1, expression 2, expressions 3)
|
||||||
function insertlater(m: text):
|
function insertlater(m: text):
|
||||||
execute "INSERT INTO `languages` VALUES (%{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%)" in {-sql}
|
execute "INSERT INTO languages VALUES (%{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%)" in {-sql}
|
||||||
function translate(m: text, p: object, variables: strings = "null") :: text:
|
function translate(m: text, p: object, variables: strings = "null") :: text:
|
||||||
|
|
||||||
#support both UUIDS and player names for getting language of the player
|
#support both UUIDS and player names for getting language of the player
|
||||||
|
|
||||||
set {_uuid} to {uuid::%{_p}%} if {name::%{_p}%} is not set else {_p}
|
set {_uuid} to {uuid::%{_p}%} if {name::%{_p}%} is not set else {_p}
|
||||||
|
|
||||||
set {_lang} to (epic variable "%{_uuid}%::language") ? "EN"
|
set {_lang} to (epic variable "%{_uuid}%::language") ? "EN"
|
||||||
if {-langmsg::%{_lang}%::%{_m}%} is not set:
|
if {-langmsg::%{_lang}%::%{_m}%} is not set:
|
||||||
|
|
||||||
set {-langmsg::%{_lang}%::%{_m}%} to {_m}
|
set {-langmsg::%{_lang}%::%{_m}%} to {_m}
|
||||||
insertlater({_m})
|
insertlater({_m})
|
||||||
|
|
||||||
#useful for knowing when was last time this message was triggered, so we can later remove messages that are never used (possibly were removed from code)
|
#useful for knowing when was last time this message was triggered, so we can later remove messages that are never used (possibly were removed from code)
|
||||||
set {-langmsgusage::%{_m}%} to now
|
set {-langmsgusage::%{_m}%} to now
|
||||||
#replace $1$, $2$, etc. stuff into proper values (function provides arguments for it)
|
#replace $1$, $2$, etc. stuff into proper values (function provides arguments for it)
|
||||||
@ -89,19 +89,19 @@ function translate(m: text, p: object, variables: strings = "null") :: text:
|
|||||||
loop {_variables::*}:
|
loop {_variables::*}:
|
||||||
replace "$%loop-index%$" with loop-value in {_msg}
|
replace "$%loop-index%$" with loop-value in {_msg}
|
||||||
return {_msg}
|
return {_msg}
|
||||||
|
|
||||||
#Translation Mode 1, return the message (MOST USEFUL!)
|
#Translation Mode 1, return the message (MOST USEFUL!)
|
||||||
return {-langmsg::%{_lang}%::%{_m}%}
|
return {-langmsg::%{_lang}%::%{_m}%}
|
||||||
|
|
||||||
#structure of table `languages_usage`
|
#structure of table languages_usage
|
||||||
#`message` = VARCHAR(333)
|
#message = VARCHAR(333)
|
||||||
#`lastused` = BIGINT(18)
|
#lastused = BIGINT(18)
|
||||||
function saveLastMessageUsageDate():
|
function saveLastMessageUsageDate():
|
||||||
|
|
||||||
loop {-langmsgusage::*}:
|
loop {-langmsgusage::*}:
|
||||||
set {_msg} to {-langmsg::en::%loop-index%}
|
set {_msg} to {-langmsg::en::%loop-index%}
|
||||||
unix timestamp of loop-value is higher than unix timestamp of {-lastlanguagesave}
|
unix timestamp of loop-value is higher than unix timestamp of {-lastlanguagesave}
|
||||||
execute "INSERT INTO `languages_usage` (`message`, `lastused`) VALUES (%{_msg}%, %unix timestamp of loop-value%) ON DUPLICATE KEY UPDATE `lastused`=VALUES(`lastused`)" in {-sql}
|
execute "INSERT INTO languages_usage (message, lastused) VALUES (%{_msg}%, %rounded unix timestamp of loop-value%) ON DUPLICATE KEY UPDATE lastused=VALUES(lastused)" in {-sql}
|
||||||
if last sql error is set:
|
if last sql error is set:
|
||||||
send last sql error to console and ops
|
send last sql error to console and ops
|
||||||
stop
|
stop
|
||||||
@ -109,83 +109,95 @@ function saveLastMessageUsageDate():
|
|||||||
every 3 hours:
|
every 3 hours:
|
||||||
send "Starting a every 3 hours task for saving last used dates of language messages to SQL." to console
|
send "Starting a every 3 hours task for saving last used dates of language messages to SQL." to console
|
||||||
saveLastMessageUsageDate()
|
saveLastMessageUsageDate()
|
||||||
|
|
||||||
function getSlotFromLanguage(lang: text) :: number:
|
function getSlotFromLanguage(lang: text) :: number:
|
||||||
switch {_lang}:
|
|
||||||
case "EN":
|
if {_lang} is "EN":
|
||||||
return 0
|
return 0
|
||||||
case "LT":
|
else if {_lang} is "LT":
|
||||||
return 1
|
return 1
|
||||||
case "RU":
|
else if {_lang} is "RU":
|
||||||
return 2
|
return 2
|
||||||
case "DA":
|
else if {_lang} is "DA":
|
||||||
return 3
|
return 3
|
||||||
case "PT":
|
else if {_lang} is "PT":
|
||||||
return 4
|
return 4
|
||||||
case "CN_Simplified":
|
else if {_lang} is "CN_Simplified":
|
||||||
return 5
|
return 5
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
command /languages [<text>]:
|
command /languages [<text>]:
|
||||||
description: Set your language
|
description: Set your language
|
||||||
usage: /languages
|
usage: /languages
|
||||||
trigger:
|
trigger:
|
||||||
wait a tick
|
wait a tick
|
||||||
open chest with 1 row named "&6- &a&lSelect language &6-" to player
|
set {_inventory} to chest inventory with 2 rows named "&6- &a&lSelect language &6-"
|
||||||
set {_inventory} to player's current inventory
|
|
||||||
|
|
||||||
#diamond block is displayed if the banner variable isn't set
|
#diamond block is displayed if the banner variable isn't set
|
||||||
set slot 0 of {_inventory} to ({banners::english} ? diamond block) named "&aEnglish" with lore "&e&lCLICK TO SELECT" with no nbt
|
set slot 0 of {_inventory} to ({banners::english} ? diamond block) named "&aEnglish" with lore "&e&lCLICK TO SELECT"
|
||||||
set slot 1 of {_inventory} to ({banners::lithuania} ? diamond block) named "&aLietuvių" with lore "&e&lCLICK TO SELECT" with no nbt
|
set slot 1 of {_inventory} to ({banners::lithuania} ? diamond block) named "&aLietuvių" with lore "&e&lCLICK TO SELECT"
|
||||||
set slot 2 of {_inventory} to ({banners::russia} ? diamond block) named "&aРусский" with lore "&e&lCLICK TO SELECT" with no nbt
|
set slot 2 of {_inventory} to ({banners::russia} ? diamond block) named "&aРусский" with lore "&e&lCLICK TO SELECT"
|
||||||
set slot 3 of {_inventory} to ({banners::denmark} ? diamond block) named "&aDansk" with lore "&e&lCLICK TO SELECT" with no nbt
|
set slot 3 of {_inventory} to ({banners::denmark} ? diamond block) named "&aDansk" with lore "&e&lCLICK TO SELECT"
|
||||||
set slot 4 of {_inventory} to ({banners::portugal} ? diamond block) named "&aPortuguês" with lore "&e&lCLICK TO SELECT" with no nbt
|
set slot 4 of {_inventory} to ({banners::portugal} ? diamond block) named "&aPortuguês" with lore "&e&lCLICK TO SELECT"
|
||||||
set slot 5 of {_inventory} to ({banners::china} ? diamond block) named "&aChinese (Simplified)" with lore "&e&lCLICK TO SELECT" with no nbt
|
set slot 5 of {_inventory} to ({banners::china} ? diamond block) named "&aChinese (Simplified)" with lore "&e&lCLICK TO SELECT"
|
||||||
|
|
||||||
set {_slot} to getSlotFromLanguage(epic variable "%uuid of player%::language")
|
set {_slot} to getSlotFromLanguage(epic variable "%uuid of player%::language")
|
||||||
set {_item} to {_inventory}.getItem({_slot})
|
set {_item} to slot {_slot} of {_inventory}
|
||||||
|
|
||||||
set lore of {_item} to "&a&lSELECTED"
|
set lore of {_item} to "&a&lSELECTED"
|
||||||
|
|
||||||
set slot {_enchantslot} of {_inventory} to {_item}
|
set slot {_slot} of {_inventory} to {_item}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set {_sp} to "Automatically detects your language based on your location."
|
set {_sp} to "Automatically detects your language based on your location."
|
||||||
|
|
||||||
if {forcedenglish::%uuid of player%} is not set:
|
if {forcedenglish::%uuid of player%} is not set:
|
||||||
set slot 8 of {_inventory} to glowing redstone dust named "&eAutomatic Language Detection &2[&a&lON&2]" with lore "&7%{_sp}%", "&7This is enabled by default.", "&a", "&a&lCLICK TO TOGGLE"
|
set slot 8 of {_inventory} to glowing redstone dust named "&eAutomatic Language Detection &2[&a&lON&2]" with lore "&7%{_sp}%", "&7This is enabled by default.", "&a", "&a&lCLICK TO TOGGLE"
|
||||||
else:
|
else:
|
||||||
set slot 8 of {_inventory} to redstone dust named "&eAutomatic Language Detection &2[&c&lOFF&2]" with lore "&7%{_sp}%", "&7This is enabled by default.", "&a", "&a&lCLICK TO TOGGLE"
|
set slot 8 of {_inventory} to redstone dust named "&eAutomatic Language Detection &2[&c&lOFF&2]" with lore "&7%{_sp}%", "&7This is enabled by default.", "&a", "&a&lCLICK TO TOGGLE"
|
||||||
|
|
||||||
|
set slot 9 of {_inventory} to arrow named "&a%translate("Go back", player)%"
|
||||||
|
open {_inventory} to player
|
||||||
on inventory click:
|
on inventory click:
|
||||||
inventory name of player's current inventory = "&6- &a&lSelect language &6-"
|
name of event-inventory = "&6- &a&lSelect language &6-"
|
||||||
|
cancel event
|
||||||
clicked inventory is not player's inventory
|
clicked inventory is not player's inventory
|
||||||
|
|
||||||
|
#Go back to Player Menu
|
||||||
|
if event-slot is arrow:
|
||||||
|
make player execute command "/playermenu"
|
||||||
|
stop
|
||||||
|
|
||||||
set {_l} to epic variable "%uuid of player%::language"
|
set {_l} to epic variable "%uuid of player%::language"
|
||||||
switch clicked slot:
|
if event-slot's index is 0:
|
||||||
case 0:
|
set {_lang} to "EN"
|
||||||
set {_lang} to "EN"
|
else if event-slot's index is 1:
|
||||||
case 1:
|
set {_lang} to "LT"
|
||||||
set {_lang} to "LT"
|
else if event-slot's index is 2:
|
||||||
case 2:
|
set {_lang} to "RU"
|
||||||
set {_lang} to "RU"
|
else if event-slot's index is 3:
|
||||||
case 3:
|
set {_lang} to "DA"
|
||||||
set {_lang} to "DA"
|
else if event-slot's index is 4:
|
||||||
case 4:
|
set {_lang} to "PT"
|
||||||
set {_lang} to "PT"
|
else if event-slot's index is 5:
|
||||||
case 5:
|
set {_lang} to "CN_Simplified"
|
||||||
set {_lang} to "CN_Simplified"
|
else if event-slot's index is 8:
|
||||||
case 8:
|
{forcedenglish::%uuid of player%} is not set:
|
||||||
{forcedenglish::%uuid of player%} is not set:
|
set {forcedenglish::%uuid of player%} to true
|
||||||
set {forcedenglish::%uuid of player%} to true
|
send "&cAutomatic language detection has been disabled."
|
||||||
send "&cAutomatic language detection has been disabled."
|
else:
|
||||||
else:
|
delete {forcedenglish::%uuid of player%}
|
||||||
delete {forcedenglish::%uuid of player%}
|
send "&aAutomatic language detection has been enabled back."
|
||||||
send "&aAutomatic language detection has been enabled back."
|
stop
|
||||||
stop
|
|
||||||
{_l} is not {_lang}:
|
{_l} is not {_lang}:
|
||||||
set epic variable "%uuid of player%::language" to {_lang}
|
set epic variable "%uuid of player%::language" to {_lang}
|
||||||
send "&eYou have selected &a%{_lang}% &elanguage!"
|
send "&eYou have selected &a%{_lang}% &elanguage!"
|
||||||
close inventory of player
|
close inventory of player
|
||||||
|
|
||||||
|
# epic variable "%uuid of player%::country" is set by LimeworkProxy on join
|
||||||
on join:
|
on join:
|
||||||
{server} is not "gl"
|
{server} is not "gl"
|
||||||
epic variable "%uuid of player%::language" is not set:
|
epic variable "%uuid of player%::language" is not set:
|
||||||
@ -195,11 +207,6 @@ on join:
|
|||||||
set {_default} to "EN"
|
set {_default} to "EN"
|
||||||
set {_p} to player
|
set {_p} to player
|
||||||
set {_uuid} to uuid of player
|
set {_uuid} to uuid of player
|
||||||
|
|
||||||
if epic variable "%uuid of player%::country" is not set:
|
|
||||||
create section stored in {_section}:
|
|
||||||
set epic variable "%{_uuid}%::country" to country of {_p}
|
|
||||||
run section {_section} async and wait
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +223,7 @@ on join:
|
|||||||
set {_lang} to "RU"
|
set {_lang} to "RU"
|
||||||
else if {_country} contains "Portugal" or "Brazil":
|
else if {_country} contains "Portugal" or "Brazil":
|
||||||
set {_lang} to "PT"
|
set {_lang} to "PT"
|
||||||
|
|
||||||
{_lang} is not epic variable "%uuid of player%::language":
|
{_lang} is not epic variable "%uuid of player%::language":
|
||||||
set epic variable "%uuid of player%::language" to {_lang}
|
set epic variable "%uuid of player%::language" to {_lang}
|
||||||
else if {_default} is set:
|
else if {_default} is set:
|
||||||
|
Loading…
Reference in New Issue
Block a user