Add files via upload
This commit is contained in:
parent
e447ea1167
commit
3f0fdb5c84
359
code/!lang.sk
359
code/!lang.sk
@ -1,160 +1,199 @@
|
|||||||
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}
|
||||||
send last sql error to console if last sql error is set
|
send last sql error to console if last sql error is set
|
||||||
#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}
|
||||||
loop {_list::*}:
|
loop {_list::*}:
|
||||||
loop {_l::%loop-value%::*}:
|
loop {_l::%loop-value%::*}:
|
||||||
if loop-value-1 is "en":
|
if loop-value-1 is "en":
|
||||||
set {_index::%loop-index-2%} to loop-value-2
|
set {_index::%loop-index-2%} to loop-value-2
|
||||||
set {langmsg::%loop-value-1%::%{_index::%loop-index-2%}%} to loop-value-2
|
set {-langmsg::%loop-value-1%::%{_index::%loop-index-2%}%} to loop-value-2
|
||||||
on script load:
|
on skript load:
|
||||||
wait a tick
|
if {langmsg::*} is set:
|
||||||
loadSQLLanguages()
|
delete {langmsg::*}
|
||||||
function SQLtoYAML():
|
on script load:
|
||||||
execute "SELECT * FROM `languages`" in {-sql} and store the result in {_l::*}
|
wait a tick
|
||||||
send last sql error to console if last sql error is set
|
loadSQLLanguages()
|
||||||
loop indexes of {_l::*}:
|
function SQLtoYAML():
|
||||||
unload yaml "lang%loop-value%"
|
execute "SELECT * FROM `languages`" in {-sql} and store the result in {_l::*}
|
||||||
load yaml "plugins/Skript/scripts/languages/Language%loop-value%.yml" as "lang%loop-value%"
|
send last sql error to console if last sql error is set
|
||||||
set {_list::%loop-value%} to loop-value
|
loop indexes of {_l::*}:
|
||||||
|
unload yaml "lang%loop-value%"
|
||||||
#done to make it the first index
|
load yaml "plugins/Skript/scripts/languages/Language%loop-value%.yml" as "lang%loop-value%"
|
||||||
set {_list::1} to "en"
|
set {_list::%loop-value%} to loop-value
|
||||||
delete {_list::en}
|
|
||||||
loop {_list::*}:
|
#done to make it the first index
|
||||||
loop {_l::%loop-value%::*}:
|
set {_list::1} to "en"
|
||||||
if loop-value-1 is "en":
|
delete {_list::en}
|
||||||
set {_index::%loop-index-2%} to loop-value-2
|
loop {_list::*}:
|
||||||
set yaml value "%{_index::%loop-index-2%}%" from "lang%loop-value-1%" to "%loop-value-2%"
|
loop {_l::%loop-value%::*}:
|
||||||
save yaml "lang%loop-value%"
|
if loop-value-1 is "en":
|
||||||
on script load:
|
set {_index::%loop-index-2%} to loop-value-2
|
||||||
send "LOADING GLOBAL LANGUAGE FILES" to console
|
set yaml value "%{_index::%loop-index-2%}%" from "lang%loop-value-1%" to "%loop-value-2%"
|
||||||
set {_languages::*} to "EN", "LT", "RU", "ES", "DA", "PT", "CN_Simplified"
|
save yaml "lang%loop-value%"
|
||||||
loop {_languages::*}:
|
on script load:
|
||||||
set {languageslist::%loop-value%} to loop-value
|
send "LOADING GLOBAL LANGUAGE FILES" to console
|
||||||
expression:
|
set {_languages::*} to "EN", "LT", "RU", "ES", "DA", "PT", "CN_Simplified"
|
||||||
patterns:
|
loop {_languages::*}:
|
||||||
translate %string% [for %player/string%] [with variables %-strings%]
|
set {languageslist::%loop-value%} to loop-value
|
||||||
translate %string% [with variables %-strings%] [for %player/string%]
|
expression:
|
||||||
get:
|
patterns:
|
||||||
if expressions 3 is not set:
|
translate %string% [for %player/string%] [with variables %-strings%]
|
||||||
return translate(expression 1, expression 2)
|
translate %string% [with variables %-strings%] [for %player/string%]
|
||||||
else:
|
get:
|
||||||
return translate(expression 1, expression 2, expressions 3)
|
if expressions 3 is not set:
|
||||||
function insertlater(m: text):
|
return translate(expression 1, expression 2)
|
||||||
execute "INSERT INTO `languages` VALUES (%{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%)" in {-sql}
|
else:
|
||||||
function translate(m: text, p: object, variables: strings = "null") :: text:
|
return translate(expression 1, expression 2, expressions 3)
|
||||||
|
function insertlater(m: text):
|
||||||
#support both UUIDS and player names for getting language of the player
|
execute "INSERT INTO `languages` VALUES (%{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%, %{_m}%)" in {-sql}
|
||||||
|
function translate(m: text, p: object, variables: strings = "null") :: text:
|
||||||
set {_uuid} to {uuid::%{_p}%} if {name::%{_p}%} is not set else {_p}
|
|
||||||
|
#support both UUIDS and player names for getting language of the player
|
||||||
set {_lang} to epic variable "%{_uuid}%::language" ? "EN"
|
|
||||||
if {langmsg::%{_lang}%::%{_m}%} is not set:
|
set {_uuid} to {uuid::%{_p}%} if {name::%{_p}%} is not set else {_p}
|
||||||
|
|
||||||
set {langmsg::%{_lang}%::%{_m}%} to {_m}
|
set {_lang} to epic variable "%{_uuid}%::language" ? "EN"
|
||||||
insertlater({_m})
|
if {-langmsg::%{_lang}%::%{_m}%} is not set:
|
||||||
|
|
||||||
#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 {-langmsg::%{_lang}%::%{_m}%} to {_m}
|
||||||
set {langmsgusage::%{_m}%} to now
|
insertlater({_m})
|
||||||
#replace $1$, $2$, etc. stuff into proper values (function provides arguments for it)
|
|
||||||
if {_variables::1} is not "null":
|
#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 {_msg} to {langmsg::%{_lang}%::%{_m}%}
|
set {-langmsgusage::%{_m}%} to now
|
||||||
loop {_variables::*}:
|
#replace $1$, $2$, etc. stuff into proper values (function provides arguments for it)
|
||||||
replace "$%loop-index%$" with loop-value in {_msg}
|
if {_variables::1} is not "null":
|
||||||
return {_msg}
|
set {_msg} to {-langmsg::%{_lang}%::%{_m}%}
|
||||||
|
loop {_variables::*}:
|
||||||
#Translation Mode 1, return the message (MOST USEFUL!)
|
replace "$%loop-index%$" with loop-value in {_msg}
|
||||||
return {langmsg::%{_lang}%::%{_m}%}
|
return {_msg}
|
||||||
|
|
||||||
function getSlotFromLanguage(lang: text) :: number:
|
#Translation Mode 1, return the message (MOST USEFUL!)
|
||||||
switch {_lang}:
|
return {-langmsg::%{_lang}%::%{_m}%}
|
||||||
case "EN":
|
|
||||||
return 0
|
function getSlotFromLanguage(lang: text) :: number:
|
||||||
case "LT":
|
switch {_lang}:
|
||||||
return 1
|
case "EN":
|
||||||
case "RU":
|
return 0
|
||||||
return 2
|
case "LT":
|
||||||
case "DA":
|
return 1
|
||||||
return 3
|
case "RU":
|
||||||
case "PT":
|
return 2
|
||||||
return 4
|
case "DA":
|
||||||
case "CN_Simplified":
|
return 3
|
||||||
return 5
|
case "PT":
|
||||||
command /languages [<text>]:
|
return 4
|
||||||
description: Set your language
|
case "CN_Simplified":
|
||||||
usage: /languages
|
return 5
|
||||||
trigger:
|
command /languages [<text>]:
|
||||||
wait a tick
|
description: Set your language
|
||||||
open chest with 1 row named "&6- &a&lSelect language &6-" to player
|
usage: /languages
|
||||||
set {_inventory} to player's current inventory
|
trigger:
|
||||||
|
wait a tick
|
||||||
#diamond block is displayed if the banner variable isn't set
|
open chest with 1 row named "&6- &a&lSelect language &6-" to player
|
||||||
set slot 0 of {_inventory} to ({banners::english} ? diamond block) named "&aEnglish" with lore "&e&lCLICK TO SELECT" with no nbt
|
set {_inventory} to player's current inventory
|
||||||
set slot 1 of {_inventory} to ({banners::lithuania} ? diamond block) named "&aLietuvių" 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" with no nbt
|
#diamond block is displayed if the banner variable isn't set
|
||||||
set slot 3 of {_inventory} to ({banners::denmark} ? diamond block) named "&aDansk" 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" with no nbt
|
||||||
set slot 4 of {_inventory} to ({banners::portugal} ? diamond block) named "&aPortuguês" 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" with no nbt
|
||||||
set slot 5 of {_inventory} to ({banners::china} ? diamond block) named "&aChinese (Simplified)" 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" with no nbt
|
||||||
|
set slot 3 of {_inventory} to ({banners::denmark} ? diamond block) named "&aDansk" with lore "&e&lCLICK TO SELECT" with no nbt
|
||||||
set {_slot} to getSlotFromLanguage(epic variable "%uuid of player%::language")
|
set slot 4 of {_inventory} to ({banners::portugal} ? diamond block) named "&aPortuguês" with lore "&e&lCLICK TO SELECT" with no nbt
|
||||||
set {_item} to {_inventory}.getItem({_slot})
|
set slot 5 of {_inventory} to ({banners::china} ? diamond block) named "&aChinese (Simplified)" with lore "&e&lCLICK TO SELECT" with no nbt
|
||||||
|
|
||||||
set lore of {_item} to "&a&lSELECTED"
|
set {_slot} to getSlotFromLanguage(epic variable "%uuid of player%::language")
|
||||||
|
set {_item} to {_inventory}.getItem({_slot})
|
||||||
set slot {_enchantslot} of {_inventory} to {_item}
|
|
||||||
|
set lore of {_item} to "&a&lSELECTED"
|
||||||
|
|
||||||
|
set slot {_enchantslot} of {_inventory} to {_item}
|
||||||
|
|
||||||
set {_sp} to "Automatically detects your language based on your location."
|
|
||||||
|
|
||||||
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 {_sp} to "Automatically detects your language based on your location."
|
||||||
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"
|
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"
|
||||||
on inventory click:
|
else:
|
||||||
inventory name of player's current inventory = "&6- &a&lSelect language &6-"
|
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"
|
||||||
clicked inventory is not player's inventory
|
|
||||||
set {_l} to epic variable "%uuid of player%::language"
|
on inventory click:
|
||||||
switch clicked slot:
|
inventory name of player's current inventory = "&6- &a&lSelect language &6-"
|
||||||
case 0:
|
clicked inventory is not player's inventory
|
||||||
set {_lang} to "EN"
|
set {_l} to epic variable "%uuid of player%::language"
|
||||||
case 1:
|
switch clicked slot:
|
||||||
set {_lang} to "LT"
|
case 0:
|
||||||
case 2:
|
set {_lang} to "EN"
|
||||||
set {_lang} to "RU"
|
case 1:
|
||||||
case 3:
|
set {_lang} to "LT"
|
||||||
set {_lang} to "DA"
|
case 2:
|
||||||
case 4:
|
set {_lang} to "RU"
|
||||||
set {_lang} to "PT"
|
case 3:
|
||||||
case 5:
|
set {_lang} to "DA"
|
||||||
set {_lang} to "CN_Simplified"
|
case 4:
|
||||||
case 8:
|
set {_lang} to "PT"
|
||||||
{forcedenglish::%uuid of player%} is not set:
|
case 5:
|
||||||
set {forcedenglish::%uuid of player%} to true
|
set {_lang} to "CN_Simplified"
|
||||||
send "&cAutomatic language detection has been disabled."
|
case 8:
|
||||||
else:
|
{forcedenglish::%uuid of player%} is not set:
|
||||||
delete {forcedenglish::%uuid of player%}
|
set {forcedenglish::%uuid of player%} to true
|
||||||
send "&aAutomatic language detection has been enabled back."
|
send "&cAutomatic language detection has been disabled."
|
||||||
{_l} is not {_lang}:
|
else:
|
||||||
set epic variable "%uuid of player%::language" to {_lang}
|
delete {forcedenglish::%uuid of player%}
|
||||||
send "&eYou have selected &a%{_lang}% &elanguage!"
|
send "&aAutomatic language detection has been enabled back."
|
||||||
close inventory of player
|
{_l} is not {_lang}:
|
||||||
|
set epic variable "%uuid of player%::language" to {_lang}
|
||||||
|
send "&eYou have selected &a%{_lang}% &elanguage!"
|
||||||
|
close inventory of player
|
||||||
|
|
||||||
|
on join:
|
||||||
|
{server} is not "gl"
|
||||||
|
epic variable "%uuid of player%::language" is not set:
|
||||||
|
|
||||||
|
set {_lang} to epic variable "%{_uuid}%::language"
|
||||||
|
if {languageslist::%{_lang}%} is not set:
|
||||||
|
set {_default} to "EN"
|
||||||
|
set {_p} to 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if {forcedenglish::%uuid of player%} is true:
|
||||||
|
epic variable "%uuid of player%::language" is not "EN"
|
||||||
|
set epic variable "%uuid of player%::language" to "EN"
|
||||||
|
else:
|
||||||
|
set {_country} to epic variable "%uuid of player%::country"
|
||||||
|
if {_country} contains "Lithuania":
|
||||||
|
set {_lang} to "LT"
|
||||||
|
else if {_country} contains "Denmark":
|
||||||
|
set {_lang} to "DA"
|
||||||
|
else if {_country} contains "Russia":
|
||||||
|
set {_lang} to "RU"
|
||||||
|
else if {_country} contains "Portugal" or "Brazil":
|
||||||
|
set {_lang} to "PT"
|
||||||
|
|
||||||
|
{_lang} is not epic variable "%uuid of player%::language":
|
||||||
|
set epic variable "%uuid of player%::language" to {_lang}
|
||||||
|
else if {_default} is set:
|
||||||
|
set epic variable "%uuid of player%::language" to {_default}
|
||||||
|
Loading…
Reference in New Issue
Block a user