Add ability to change icon in Warps panel. (#24)
This commit is contained in:
parent
bfbf95486f
commit
0f9232d016
|
@ -14,6 +14,8 @@ import world.bentobox.bentobox.api.panels.PanelItem;
|
|||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.ItemParser;
|
||||
|
||||
|
||||
public class WarpPanelManager {
|
||||
|
||||
|
@ -29,8 +31,32 @@ public class WarpPanelManager {
|
|||
|
||||
private PanelItem getPanelItem(World world, UUID warpOwner) {
|
||||
// Return a sign panel item
|
||||
return new PanelItemBuilder()
|
||||
.icon(Material.SIGN)
|
||||
|
||||
PanelItemBuilder builder = new PanelItemBuilder();
|
||||
|
||||
if (this.addon.getSettings().getIcon().equals("PLAYER"))
|
||||
{
|
||||
String playerName = this.addon.getPlayers().getName(warpOwner);
|
||||
|
||||
if (!playerName.isEmpty())
|
||||
{
|
||||
builder.icon(playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If player name is not found then use default icon.
|
||||
|
||||
ItemStack itemStack = ItemParser.parse(this.addon.getSettings().getIcon() + ":1");
|
||||
builder.icon(itemStack == null ? Material.SIGN : itemStack.getType());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ItemParser.parse(this.addon.getSettings().getIcon() + ":1");
|
||||
builder.icon(itemStack == null ? Material.SIGN : itemStack.getType());
|
||||
}
|
||||
|
||||
return builder
|
||||
.name(addon.getPlugin().getPlayers().getName(warpOwner))
|
||||
.description(getSign(world, warpOwner))
|
||||
.clickHandler((panel, clicker, click, slot) -> { {
|
||||
|
|
|
@ -29,6 +29,13 @@ public class Settings implements DataObject
|
|||
@ConfigEntry(path = "welcomeLine")
|
||||
private String welcomeLine;
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Icon that will be displayed in Warps list.")
|
||||
@ConfigComment("It uses native Minecraft material strings, but using string 'PLAYER', it is possible to")
|
||||
@ConfigComment("use player heads instead.")
|
||||
@ConfigEntry(path = "icon")
|
||||
private String icon = "SIGN";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("This list stores GameModes in which Level addon should not work.")
|
||||
@ConfigComment("To disable addon it is necessary to write its name in new line that starts with -. Example:")
|
||||
|
@ -139,4 +146,24 @@ public class Settings implements DataObject
|
|||
{
|
||||
this.disabledGameModes = disabledGameModes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the icon object.
|
||||
* @return the icon object.
|
||||
*/
|
||||
public String getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the icon object value.
|
||||
* @param icon the icon object new value.
|
||||
*/
|
||||
public void setIcon(String icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,12 @@ warplevelrestriction: 10
|
|||
# Text that player must put on sign to make it a warp sign
|
||||
# Not case sensitive!
|
||||
welcomeLine: '[Welcome]'
|
||||
#
|
||||
#
|
||||
# Icon that will be displayed in Warps list.
|
||||
# It uses native Minecraft material strings, but using string 'PLAYER', it is possible to
|
||||
# use player heads instead.
|
||||
icon: 'SIGN'
|
||||
#
|
||||
# This list stores GameModes in which Level addon should not work.
|
||||
# To disable addon it is necessary to write its name in new line that starts with -. Example:
|
||||
# disabled-gamemodes:
|
||||
|
|
Loading…
Reference in New Issue