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
b6ba2b60
Commit
b6ba2b60
authored
Nov 28, 2016
by
kellerkindt
Browse files
Added HoverText which is also customizable as a player
parent
1e5f0d98
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/com/kellerkindt/scs/SCSConfiguration.java
View file @
b6ba2b60
...
...
@@ -46,7 +46,9 @@ public class SCSConfiguration extends Configuration {
public
static
final
String
KEY_CREATEPRICE_DISPLAY
=
"CreatePrice.Display"
;
public
static
final
String
KEY_CREATEPRICE_EXCHANGE
=
"CreatePrice.Exchange"
;
public
static
final
String
KEY_VISIBLE_CUSTOM_NAME
=
"Visible.CustomName"
;
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_SAVE_INTERVAL
=
"Save.Interval"
;
...
...
@@ -99,6 +101,7 @@ public class SCSConfiguration extends Configuration {
// "import" old values / apply updates
rename
(
"DefaultUnit"
,
"Default.Unit"
);
// 2014-03-02
rename
(
"DefaultShowTransactionMessages"
,
"Default.ShowTransactionMessages"
);
// 2014-03-02
rename
(
"Visible.CustomName"
,
"HoverText.Enabled"
);
// 2016-11-28
// update / set the configuration with default values
...
...
@@ -181,8 +184,16 @@ public class SCSConfiguration extends Configuration {
return
getForced
(
KEY_SAVE_INTERVAL
,
60
l
);
}
public
boolean
isCustomNameVisible
()
{
return
getForced
(
KEY_VISIBLE_CUSTOM_NAME
,
true
);
public
boolean
isHoverTextEnabled
()
{
return
getForced
(
KEY_HOVER_TEXT_ENABLED
,
true
);
}
public
boolean
isHoverTextPlayerCustomNameEnabled
()
{
return
getForced
(
KEY_HOVER_TEXT_PLAYER_CUSTOM_NAME_ENABLED
,
true
);
}
public
int
getHoverTextPlayerCustomNameMaxLength
()
{
return
getForced
(
KEY_HOVER_TEXT_PLAYER_CUSTOM_NAME_MAX_LENGTH
,
32
);
}
public
boolean
isDebuggingSave
()
{
...
...
src/com/kellerkindt/scs/commands/Help.java
View file @
b6ba2b60
...
...
@@ -73,7 +73,6 @@ public class Help extends SimpleCommand {
Term
.
HELP_27
.
get
(),
Term
.
HELP_14
.
get
(),
Term
.
HELP_15
.
get
(),
Term
.
HELP_24
.
get
()
)));
...
...
@@ -90,7 +89,8 @@ public class Help extends SimpleCommand {
Term
.
HELP_22
.
get
(),
Term
.
HELP_28
.
get
(),
Term
.
HELP_29
.
get
(),
Term
.
HELP_30
.
get
()
Term
.
HELP_30
.
get
(),
Term
.
HELP_31
.
get
()
)));
}
...
...
src/com/kellerkindt/scs/commands/HoverText.java
0 → 100644
View file @
b6ba2b60
/*
* ShowCaseStandalone - A Minecraft-Bukkit-API Shop Plugin
* Copyright (C) 2016-11-28 22:51 +01 kellerkindt (Michael Watzko) <copyright at kellerkindt.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
com.kellerkindt.scs.commands
;
import
com.kellerkindt.scs.ShopManipulator
;
import
com.kellerkindt.scs.ShowCaseStandalone
;
import
com.kellerkindt.scs.shops.Shop
;
import
org.bukkit.command.CommandSender
;
import
org.bukkit.entity.Player
;
import
java.util.Collections
;
/**
* @author Michael Watzko <michael at kellerkindt.com>
*/
public
class
HoverText
extends
SimpleCommand
{
public
HoverText
(
ShowCaseStandalone
scs
,
String
...
permissions
)
{
super
(
scs
,
permissions
,
true
,
0
);
}
@Override
public
java
.
util
.
List
<
String
>
getTabCompletions
(
CommandSender
sender
,
String
[]
args
)
{
return
Collections
.
emptyList
();
}
@Override
public
void
execute
(
CommandSender
sender
,
String
[]
args
)
throws
CommandException
{
String
text
=
null
;
if
(
args
.
length
>
0
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
args
[
0
]);
for
(
int
i
=
1
;
i
<
args
.
length
;
++
i
)
{
builder
.
append
(
' '
);
builder
.
append
(
args
[
i
]);
}
text
=
builder
.
toString
();
}
final
String
hoverText
=
text
;
registerShopManipulator
(
(
Player
)
sender
,
new
ShopManipulator
()
{
@Override
public
void
manipulate
(
Shop
shop
)
{
shop
.
setCustomHoverText
(
hoverText
);
scs
.
getShopHandler
().
hide
(
shop
);
scs
.
getShopHandler
().
show
(
shop
);
}
@Override
public
boolean
requiresValidShop
()
{
return
true
;
}
}
);
}
}
src/com/kellerkindt/scs/internals/SimpleShopHandler.java
View file @
b6ba2b60
...
...
@@ -25,13 +25,14 @@ import com.kellerkindt.scs.events.ShowCaseShopHandlerChangedEvent;
import
com.kellerkindt.scs.interfaces.Changeable
;
import
com.kellerkindt.scs.interfaces.ShopHandler
;
import
com.kellerkindt.scs.interfaces.StorageHandler
;
import
com.kellerkindt.scs.shops.BuyShop
;
import
com.kellerkindt.scs.shops.SellShop
;
import
com.kellerkindt.scs.shops.Shop
;
import
com.kellerkindt.scs.utilities.ItemStackUtilities
;
import
com.kellerkindt.scs.utilities.MaterialNames
;
import
com.kellerkindt.scs.utilities.Messaging
;
import
com.kellerkindt.scs.utilities.Term
;
import
org.bukkit.Chunk
;
import
org.bukkit.Location
;
import
org.bukkit.Material
;
import
org.bukkit.World
;
import
org.bukkit.*
;
import
org.bukkit.block.Block
;
import
org.bukkit.block.BlockFace
;
import
org.bukkit.enchantments.Enchantment
;
...
...
@@ -762,8 +763,20 @@ public class SimpleShopHandler implements ShopHandler, Listener {
}
// TODO experimental
if
(
scs
.
getConfiguration
().
isCustomNameVisible
())
{
item
.
setCustomName
(
Term
.
SIGN_PRICE
.
get
(
String
.
format
(
"%.2f"
,
shop
.
getPrice
())));
if
(
scs
.
getConfiguration
().
isHoverTextEnabled
())
{
if
(
scs
.
getConfiguration
().
isHoverTextPlayerCustomNameEnabled
()
&&
shop
.
getCustomHoverText
()
!=
null
)
{
String
hoverText
=
shop
.
getCustomHoverText
();
if
(
hoverText
.
length
()
>
scs
.
getConfiguration
().
getHoverTextPlayerCustomNameMaxLength
())
{
hoverText
=
hoverText
.
substring
(
0
,
scs
.
getConfiguration
().
getHoverTextPlayerCustomNameMaxLength
());
}
// mark player text differently so one can distinguish between original SCS price and fake price
item
.
setCustomName
(
ChatColor
.
YELLOW
+
"["
+
hoverText
+
"]"
);
}
else
{
item
.
setCustomName
(
ChatColor
.
GREEN
+
shop
.
getHoverText
());
}
item
.
setCustomNameVisible
(
true
);
}
...
...
src/com/kellerkindt/scs/listeners/CommandExecutorListener.java
View file @
b6ba2b60
...
...
@@ -56,6 +56,7 @@ public class CommandExecutorListener implements CommandExecutor, TabCompleter {
commands
.
add
(
new
That
(
scs
,
Properties
.
PERMISSION_CREATE_EXCHANGE
));
commands
.
add
(
new
Get
(
scs
,
Properties
.
PERMISSION_MANAGE
));
commands
.
add
(
new
Help
(
scs
,
Properties
.
PERMISSION_USE
,
Properties
.
PERMISSION_ADMIN
));
commands
.
add
(
new
HoverText
(
scs
,
Properties
.
PERMISSION_MANAGE
));
commands
.
add
(
new
Last
(
scs
,
Properties
.
PERMISSION_USE
));
commands
.
add
(
new
com
.
kellerkindt
.
scs
.
commands
.
List
(
scs
,
Properties
.
PERMISSION_ADMIN
));
commands
.
add
(
new
Member
(
scs
,
Properties
.
PERMISSION_MANAGE
));
...
...
src/com/kellerkindt/scs/shops/BuyShop.java
View file @
b6ba2b60
...
...
@@ -79,6 +79,11 @@ public class BuyShop<T extends BuyShop<?>> extends Shop<T> {
return
list
;
}
@Override
public
String
getHoverText
()
{
return
getHoverText
(
Term
.
SHOP_ITEM_CUSTOM_NAME_TYPE_BUY
);
}
/**
* @param amount The new max amount to buy for this {@link BuyShop}
* @return itself
...
...
src/com/kellerkindt/scs/shops/DisplayShop.java
View file @
b6ba2b60
...
...
@@ -70,6 +70,11 @@ public class DisplayShop extends Shop {
return
list
;
}
@Override
public
String
getHoverText
()
{
return
getHoverText
(
Term
.
SHOP_ITEM_CUSTOM_NAME_TYPE_DISPLAY
);
}
/**
* @see ConfigurationSerializable
*/
...
...
src/com/kellerkindt/scs/shops/ExchangeShop.java
View file @
b6ba2b60
...
...
@@ -79,6 +79,17 @@ public class ExchangeShop<T extends ExchangeShop<?>> extends Shop<T> {
return
list
;
}
@Override
public
String
getHoverText
()
{
return
getHoverText
(
Term
.
SHOP_ITEM_CUSTOM_NAME_TYPE_EXCHANGE
);
}
@Override
protected
String
getHoverText
(
Term
term
,
List
<
String
>
parameters
)
{
parameters
.
add
(
MaterialNames
.
getItemName
(
getExchangeItemStack
()));
return
super
.
getHoverText
(
term
,
parameters
);
}
/**
* @see com.kellerkindt.scs.shops.Shop#serialize()
*/
...
...
src/com/kellerkindt/scs/shops/SellShop.java
View file @
b6ba2b60
...
...
@@ -69,6 +69,11 @@ public class SellShop extends Shop {
return
list
;
}
@Override
public
String
getHoverText
()
{
return
getHoverText
(
Term
.
SHOP_ITEM_CUSTOM_NAME_TYPE_SELL
);
}
/**
* @see ConfigurationSerializable
*/
...
...
src/com/kellerkindt/scs/shops/Shop.java
View file @
b6ba2b60
...
...
@@ -49,6 +49,7 @@ public abstract class Shop<T extends Shop<?>> extends SimpleChangeable<T> implem
public
static
final
String
KEY_UNLIMITED
=
"unlimited"
;
public
static
final
String
KEY_ITEMSTACK
=
"itemstack"
;
public
static
final
String
KEY_MEMBERS
=
"members"
;
public
static
final
String
KEY_CUSTOM_HOVER
=
"customHoverText"
;
public
static
final
String
KEY_OWNER
=
"owner"
;
public
static
final
String
KEY_WORLD
=
"world"
;
...
...
@@ -71,6 +72,8 @@ public abstract class Shop<T extends Shop<?>> extends SimpleChangeable<T> implem
protected
NamedUUID
owner
=
null
;
protected
List
<
NamedUUID
>
members
=
new
ArrayList
<
NamedUUID
>();
protected
String
customHoverText
=
null
;
protected
Shop
()
{
// for deserialization
...
...
@@ -644,8 +647,8 @@ public abstract class Shop<T extends Shop<?>> extends SimpleChangeable<T> implem
for
(
NamedUUID
member
:
getMembers
())
{
members
.
add
(
member
);
}
map
.
put
(
KEY_MEMBERS
,
members
);
map
.
put
(
KEY_MEMBERS
,
members
);
map
.
put
(
KEY_CUSTOM_HOVER
,
customHoverText
);
map
.
put
(
KEY_OWNER
,
owner
);
map
.
put
(
KEY_WORLD
,
world
);
...
...
@@ -828,10 +831,13 @@ public abstract class Shop<T extends Shop<?>> extends SimpleChangeable<T> implem
this
.
members
.
clear
();
this
.
members
.
addAll
((
List
<
NamedUUID
>)
map
.
get
(
KEY_MEMBERS
));
this
.
customHoverText
=
(
String
)
map
.
get
(
KEY_CUSTOM_HOVER
);
this
.
owner
=
(
NamedUUID
)
map
.
get
(
KEY_OWNER
);
this
.
world
=
(
NamedUUID
)
map
.
get
(
KEY_WORLD
);
List
<
Double
>
listLocation
=
(
List
<
Double
>)
map
.
get
(
KEY_LOCATION
);
World
world
=
this
.
world
.
getId
()
!=
null
?
server
.
getWorld
(
this
.
world
.
getId
())
:
null
;
...
...
@@ -897,6 +903,59 @@ public abstract class Shop<T extends Shop<?>> extends SimpleChangeable<T> implem
*/
public
abstract
List
<
String
>
getDescription
();
/**
* @return The hover text of this {@link Shop}
*/
public
abstract
String
getHoverText
();
/**
* @param term {@link Term} to get the hover text from
* @return The hover text with default values passed to the given {@link Term}
*/
protected
String
getHoverText
(
Term
term
)
{
return
getHoverText
(
term
,
Arrays
.
asList
(
MaterialNames
.
getItemName
(
getItemStack
()),
scs
.
getBalanceHandler
().
format
(
getPrice
()),
getOwnerName
(),
Integer
.
toString
(
getAmount
()),
Boolean
.
toString
(
isUnlimited
())
)
);
}
/**
* @param term {@link Term} to get the hover text from
* @param parameters {@link List} of parameters to pass to the {@link Term}
* @return The hover text of this {@link Shop}
*/
protected
String
getHoverText
(
Term
term
,
List
<
String
>
parameters
)
{
return
term
.
get
(
parameters
.
toArray
(
new
String
[
parameters
.
size
()]
)
);
}
/**
* @return The custom hover text for this {@link Shop}
*/
public
String
getCustomHoverText
()
{
return
customHoverText
;
}
/**
* @param text The new custom hover text for this {@link Shop}
* @return itself
*/
public
T
setCustomHoverText
(
String
text
)
{
return
setChanged
(
!
Objects
.
equals
(
text
,
customHoverText
),
()
->
this
.
customHoverText
=
text
);
}
/**
* Adds a description for {@link Enchantment}s on the
* given {@link ItemStack}. Won't add anything if there
...
...
src/com/kellerkindt/scs/utilities/Term.java
View file @
b6ba2b60
...
...
@@ -17,6 +17,8 @@
*/
package
com.kellerkindt.scs.utilities
;
import
com.kellerkindt.scs.shops.*
;
public
enum
Term
{
ABORT
,
DISABLE
,
...
...
@@ -186,6 +188,7 @@ public enum Term {
HELP_28
,
// about
HELP_29
,
// version
HELP_30
,
// range
HELP_31
,
// hover text
HELP_ADMIN_1
,
HELP_ADMIN_2
,
HELP_ADMIN_3
,
...
...
@@ -249,8 +252,55 @@ public enum Term {
RESTORE_END
,
DELETE_START
,
DELETE_END
,
/**
* The custom name value for the item
* that is floating above the shop
*
* %1 material name
* %2 formatted price
* %3 shop owner
* %4 shop amount
* %5 whether unlimited
*/
SHOP_ITEM_CUSTOM_NAME_TYPE_SELL
,
/**
* The custom name value for the item
* that is floating above the shop
*
* %1 material name
* %2 formatted price
* %3 shop owner
* %4 shop amount
* %5 whether unlimited
*/
SHOP_ITEM_CUSTOM_NAME_TYPE_BUY
,
/**
* The custom name value for the item
* that is floating above the shop
*
* %1 material name
* %2 formatted price
* %3 shop owner
* %4 shop amount
* %5 whether unlimited
* %6 exchange material name
*/
SHOP_ITEM_CUSTOM_NAME_TYPE_EXCHANGE
,
/**
* The custom name value for the item
* that is floating above the shop
*
* %1 material name
* %2 formatted price
* %3 shop owner
* %4 shop amount
* %5 whether unlimited
*/
SHOP_ITEM_CUSTOM_NAME_TYPE_DISPLAY
;
private
String
term
=
null
;
...
...
src/locale_DE.yml
View file @
b6ba2b60
...
...
@@ -166,6 +166,7 @@ HELP_27: "`g/scs member <add|remove> {name}
HELP_28
:
"
`g/scs
about
`G
-
Zeigt
informationen
ueber
dieses
Plugin
an"
HELP_29
:
"
`g/scs
version
`G
-
Zeigt
informationen
ueber
diese
Version
an"
HELP_30
:
"
`g/scs
range
<remove/material/global>
<material/min>
[max]
`G
-
Erstellt
oder
entfernt
eine
Preisbeschraenkung
fuer
das
angegeben
Material
oder
global"
HELP_31
:
"
`g/scs
hovertext
{text}`G
-
Zu
hovernder
Text
oder
nichts
zum
entfernen"
HELP_ADMIN_1
:
"
`g/scs
clear
`G-
entfernt
temporaer
alle
schwebenden
Items."
HELP_ADMIN_2
:
"
`g/scs
disable
`G-
deaktiviert
alle
ShowCase."
HELP_ADMIN_3
:
"
`g/scs
enable
`G-
aktiviert
alle
ShowCase."
...
...
@@ -211,3 +212,20 @@ RESTORE_START: "`yStelle ShowCases wieder her..."
RESTORE_END
:
"
`gWiederherstellung
von
%1
ShowCases
beendet."
DELETE_START
:
"
`yL�sche
ShowCases."
DELETE_END
:
"
`g%1
ShowCases
wurden
gel�scht"
##
## The custom name value for the item
## that is floating above the shop
##
## %1 material name
## %2 formatted price
## %3 shop owner
## %4 shop type
## %5 shop amount
## %6 whether unlimited
##
SHOP_ITEM_CUSTOM_NAME_TYPE_SELL
:
"
Verkaufe
%1
fuer
jeweils
%2"
SHOP_ITEM_CUSTOM_NAME_TYPE_BUY
:
"
Kaufe
%1
fuer
jeweils
%2"
SHOP_ITEM_CUSTOM_NAME_TYPE_EXCHANGE
:
"
Tausche
%1"
SHOP_ITEM_CUSTOM_NAME_TYPE_DISPLAY
:
"
Zeige
%1"
\ No newline at end of file
src/locale_EN.yml
View file @
b6ba2b60
...
...
@@ -166,6 +166,7 @@ HELP_27: "`g/scs member <add|remove> {name}
HELP_28
:
"
`g/scs
about
`G
-
Shows
information
about
this
plugin"
HELP_29
:
"
`g/scs
version
`G
-
Shows
information
about
this
version"
HELP_30
:
"
`g/scs
range
<remove/material/global>
<material/min>
[max]
`G
-
Creates
or
removes
a
PriceRange
for
the
requested
Material
or
globally"
HELP_31
:
"
`g/scs
hovertext
{text}`G
-
Text
to
hover
above
shop
or
no
text
to
remove"
HELP_ADMIN_1
:
"
`g/scs
clear
`G-
Temporarily
clear
the
floating
shop
items."
HELP_ADMIN_2
:
"
`g/scs
disable
`G-
Disable
all
of
the
shops."
HELP_ADMIN_3
:
"
`g/scs
enable
`G-
Enable
all
of
the
shops."
...
...
@@ -212,3 +213,20 @@ RESTORE_START: "`yGoing to repair ShowCases."
RESTORE_END
:
"
`gRepaired
%1
damaged
ShowCases."
DELETE_START
:
"
`yGoing
to
delete
ShowCases."
DELETE_END
:
"
`gDeleted
%1
damaged
ShowCases."
##
## The custom name value for the item
## that is floating above the shop
##
## %1 material name
## %2 formatted price
## %3 shop owner
## %4 shop type
## %5 shop amount
## %6 whether unlimited
##
SHOP_ITEM_CUSTOM_NAME_TYPE_SELL
:
"
Selling
%1
for
%2
each"
SHOP_ITEM_CUSTOM_NAME_TYPE_BUY
:
"
Buying
%1
for
%2
each"
SHOP_ITEM_CUSTOM_NAME_TYPE_EXCHANGE
:
"
Trading
%1"
SHOP_ITEM_CUSTOM_NAME_TYPE_DISPLAY
:
"
Displaying
%1"
\ No newline at end of file
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