Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Watzko
ShowCaseStandalone
Commits
3bdded28
Commit
3bdded28
authored
Nov 29, 2016
by
kellerkindt
Browse files
Using custom formatter if formatted text from Balance hook is too long
parent
53e745bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/com/kellerkindt/scs/SCSConfiguration.java
View file @
3bdded28
...
...
@@ -49,6 +49,8 @@ public class SCSConfiguration extends Configuration {
public
static
final
String
KEY_HOVER_TEXT_ENABLED
=
"HoverText.Enabled"
;
public
static
final
String
KEY_HOVER_TEXT_PLAYER_CUSTOM_NAME_ENABLED
=
"HoverText.PlayerCustomNameEnabled"
;
public
static
final
String
KEY_HOVER_TEXT_PLAYER_CUSTOM_NAME_MAX_LENGTH
=
"HoverText.PlayerCustomNameMaxLength"
;
public
static
final
String
KEY_HOVER_TEXT_BALANCE_MAX_LENGTH
=
"HoverText.BalanceMaxLength"
;
public
static
final
String
KEY_HOVER_TEXT_BALANCE_FORMATTER
=
"HoverText.BalanceFormatter"
;
public
static
final
String
KEY_SAVE_INTERVAL
=
"Save.Interval"
;
...
...
@@ -196,6 +198,17 @@ public class SCSConfiguration extends Configuration {
return
getForced
(
KEY_HOVER_TEXT_PLAYER_CUSTOM_NAME_MAX_LENGTH
,
32
);
}
/**
* @return The maximum allowed length of the hover text if formatted by the balance hook
*/
public
int
getHoverTextBalanceMaxLength
()
{
return
getForced
(
KEY_HOVER_TEXT_BALANCE_MAX_LENGTH
,
7
);
}
public
String
getHoverTextBalanceFormatter
()
{
return
getForced
(
KEY_HOVER_TEXT_BALANCE_FORMATTER
,
".2f$"
);
}
public
boolean
isDebuggingSave
()
{
return
getForced
(
KEY_DEBUG_SAVE
,
false
);
}
...
...
src/com/kellerkindt/scs/shops/Shop.java
View file @
3bdded28
...
...
@@ -19,6 +19,7 @@ package com.kellerkindt.scs.shops;
import
com.kellerkindt.scs.Properties
;
import
com.kellerkindt.scs.SCSConfiguration
;
import
com.kellerkindt.scs.ShowCaseStandalone
;
import
com.kellerkindt.scs.internals.NamedUUID
;
import
com.kellerkindt.scs.internals.SimpleChangeable
;
...
...
@@ -913,12 +914,22 @@ public abstract class Shop<T extends Shop<?>> extends SimpleChangeable<T> implem
* @return The hover text with default values passed to the given {@link Term}
*/
protected
String
getHoverText
(
Term
term
)
{
String
formattedPrice
=
scs
.
getBalanceHandler
().
format
(
getPrice
());
SCSConfiguration
configuration
=
scs
.
getConfiguration
();
if
(
formattedPrice
.
length
()
>
configuration
.
getHoverTextPlayerCustomNameMaxLength
())
{
formattedPrice
=
String
.
format
(
configuration
.
getHoverTextBalanceFormatter
(),
getPrice
()
);
}
return
getHoverText
(
term
,
new
ArrayList
<>(
Arrays
.
asList
(
MaterialNames
.
getItemName
(
getItemStack
()),
scs
.
getBalanceHandler
().
format
(
get
Price
())
,
format
ted
Price
,
getOwnerName
(),
Integer
.
toString
(
getAmount
()),
Boolean
.
toString
(
isUnlimited
())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment