Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added client based item translation to store.sk #182

Merged
merged 3 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion SkyBlock/SKYBLOCK.SK/Functions/openbook.sk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# ==============
# openbook.sk v0.0.3
# openbook.sk v0.0.4
# ==============
# Opens a book from the server side on the client.
# ==============
Expand Down Expand Up @@ -109,3 +109,13 @@ function getTranslatableComponentFromItem(item:item) :: object:
set {_vname} to "item.%{_vname}%"
set {_item} to new TranslatableComponent({_vname})
return new TranslatableComponent({_vname})

#
# > Function - newTextComponent
# > Parameters:
# > <text>the text which should be created as text component
# > Actions:
# > Returns a new text component, removes the need to import
# > the neccessary classes everywhere.
function newTextComponent(text:text) :: object:
return new TextComponent({_text})
39 changes: 22 additions & 17 deletions SkyBlock/addons/store.sk
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,14 @@ function storeshophandler(player:player,action:text,shop:text,itemshopid:number,
# > Remove the money from the player, send a success message and
# > give the player the item.
remove {_price} from {_player}'s balance
set {_msg} to {SB::lang::store::boughtxitems::%{_lang}%}
replace all "<item>" with "%{_item}%" in {_msg}
replace all "<price>" with "%{_price}%" in {_msg}
replace all "<currency>" with "%{_currency}%" in {_msg}
message "%{_prefix}% %{_msg}%" to {_player}
#
# > Create new Text Components to send them to the player. Also sends an
# > TranslatableComponent, which is going to be translated by the client.
set {_langmsg::*} to {SB::lang::store::boughtxitems::%{_lang}%} split at "<ph>"
set {_msg} to newTextComponent("%{_prefix}% %{_langmsg::1}%%{_item}.getAmount()% %{_langmsg::2}%")
{_msg}.addExtra(getTranslatableComponentFromItem({_item}))
{_msg}.addExtra(newTextComponent("%{_langmsg::3}%%{_price}% %{_currency}%%{_langmsg::4}%"))
{_player}.sendMessage({_msg})
give {_item} to {_player}'s inventory
#
# > The player has not enough space, send a error message.
Expand Down Expand Up @@ -662,12 +665,13 @@ function storeshophandler(player:player,action:text,shop:text,itemshopid:number,
# > has in his inventory.
set {_price} to {_price} * number of {_item} in {_player}'s inventory
#
# > Set success message and replace placeholders, then send it to the player.
set {_msg} to {SB::lang::store::soldxitems::%{_lang}%}
replace all "<item>" with "%number of {_item} in {_player}'s inventory% %1 of {_item}%" in {_msg}
replace all "<price>" with "%{_price}%" in {_msg}
replace all "<currency>" with "%{_currency}%" in {_msg}
message "%{_prefix}% %{_msg}%" to {_player}
# > Create new Text Components to send them to the player. Also sends an
# > TranslatableComponent, which is going to be translated by the client.
set {_langmsg::*} to {SB::lang::store::soldxitems::%{_lang}%} split at "<ph>"
set {_msg} to newTextComponent("%{_prefix}% %{_langmsg::1}%%number of {_item} in {_player}'s inventory% %{_langmsg::2}%")
{_msg}.addExtra(getTranslatableComponentFromItem({_item}))
{_msg}.addExtra(newTextComponent("%{_langmsg::3}%%{_price}% %{_currency}%%{_langmsg::4}%"))
{_player}.sendMessage({_msg})
#
# > Remove all the defined items and give the player the calculated money. Then stop.
remove number of {_item} in {_player}'s inventory of {_item} from {_player}'s inventory
Expand All @@ -678,12 +682,13 @@ function storeshophandler(player:player,action:text,shop:text,itemshopid:number,
# > amount in his inventory.
else if {_player}'s inventory has {_item}:
#
# > Send success message to the player. Replace placeholders.
set {_msg} to {SB::lang::store::soldxitems::%{_lang}%}
replace all "<item>" with "%{_item}%" in {_msg}
replace all "<price>" with "%{_price}%" in {_msg}
replace all "<currency>" with "%{_currency}%" in {_msg}
message "%{_prefix}% %{_msg}%" to {_player}
# > Create new Text Components to send them to the player. Also sends an
# > TranslatableComponent, which is going to be translated by the client.
set {_langmsg::*} to {SB::lang::store::soldxitems::%{_lang}%} split at "<ph>"
set {_msg} to newTextComponent("%{_prefix}% %{_langmsg::1}%%{_item}.getAmount()% %{_langmsg::2}%")
{_msg}.addExtra(getTranslatableComponentFromItem({_item}))
{_msg}.addExtra(newTextComponent("%{_langmsg::3}%%{_price}% %{_currency}%%{_langmsg::4}%"))
{_player}.sendMessage({_msg})
#
# > Remove the item from the inventory of the player and give the money.
remove {_item} from {_player}'s inventory
Expand Down
6 changes: 3 additions & 3 deletions SkyBlock/lang/de.sk
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ on script load:
set {SB::lang::store::cantsell::%{_lang}%} to "&7Dieser Gegenstand ist\n&7nicht verkaufbar."
set {SB::lang::store::itemselllore::%{_lang}%} to "&7Ertrag: <amount> <currency>\n&7Klicke hier, um diesen\n&7Gegenstand zu verkaufen."
set {SB::lang::store::itembuylore::%{_lang}%} to "&7Preis: <amount> <currency>\n&7Klicke hier, um diesen\n&7Gegenstand zu kaufen."
set {SB::lang::store::soldxitems::%{_lang}%} to "Du hast <item> für <price> <currency> verkauft."
set {SB::lang::store::boughtxitems::%{_lang}%} to "Du hast <item> für <price> <currency> gekauft."
set {SB::lang::store::notenoughitem::%{_lang}%} to "Du hast nicht <item>."
set {SB::lang::store::soldxitems::%{_lang}%} to "Du hast <ph><ph> für <ph> verkauft."
set {SB::lang::store::boughtxitems::%{_lang}%} to "Du hast <ph><ph> für <ph> gekauft."
set {SB::lang::store::notenoughitem::%{_lang}%} to "Du hast genug <ph>."

#
# > Lootbox
Expand Down