Adds the missing support for PLAYER_HEAD icons

https://github.com/BentoBoxWorld/Warps/issues/38
This commit is contained in:
tastybento 2019-08-22 15:08:14 -07:00
parent 633f2a63e2
commit c671e35661
4 changed files with 22 additions and 14 deletions

View File

@ -29,9 +29,7 @@ public class WarpPanelManager {
} }
private PanelItem getPanelItem(World world, UUID warpOwner) { private PanelItem getPanelItem(World world, UUID warpOwner) {
// Return a sign panel item PanelItemBuilder pib = new PanelItemBuilder()
return new PanelItemBuilder()
.icon(getSignIcon(world, warpOwner))
.name(addon.getPlugin().getPlayers().getName(warpOwner)) .name(addon.getPlugin().getPlayers().getName(warpOwner))
.description(getSign(world, warpOwner)) .description(getSign(world, warpOwner))
.clickHandler((panel, clicker, click, slot) -> { { .clickHandler((panel, clicker, click, slot) -> { {
@ -39,7 +37,13 @@ public class WarpPanelManager {
addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner); addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner);
return true; return true;
} }
}).build(); });
Material icon = getSignIcon(world, warpOwner);
if (icon.equals(Material.PLAYER_HEAD)) {
return pib.icon(addon.getPlayers().getName(warpOwner)).build();
} else {
return pib.icon(icon).build();
}
} }
private Material getSignIcon(World world, UUID warpOwner) { private Material getSignIcon(World world, UUID warpOwner) {

View File

@ -262,8 +262,12 @@ public class WarpSignsManager {
// Remove any trailing blank lines // Remove any trailing blank lines
result.removeIf(String::isEmpty); result.removeIf(String::isEmpty);
// Get the sign type // Get the sign type
Material type = Material.valueOf(sign.getType().name().replace("WALL_", "")); Material icon = Material.matchMaterial(addon.getSettings().getIcon());
return new SignCache(result, type); if (icon == null || icon.name().contains("SIGN")) {
return new SignCache(result, Material.valueOf(sign.getType().name().replace("WALL_", "")));
} else {
return new SignCache(result, icon);
}
} else { } else {
addon.getWarpSignsManager().removeWarp(world, uuid); addon.getWarpSignsManager().removeWarp(world, uuid);
} }

View File

@ -30,9 +30,10 @@ public class Settings implements ConfigObject
private String welcomeLine; private String welcomeLine;
@ConfigComment("") @ConfigComment("")
@ConfigComment("Icon that will be displayed in Warps list.") @ConfigComment("Icon that will be displayed in Warps list. SIGN counts for any kind of sign and the type of")
@ConfigComment("It uses native Minecraft material strings, but using string 'PLAYER', it is possible to") @ConfigComment("wood used will be reflected in the panel if the server supports it.")
@ConfigComment("use player heads instead.") @ConfigComment("It uses native Minecraft material strings, but using string 'PLAYER_HEAD', it is possible to")
@ConfigComment("use player heads instead. Beware that Mojang API rate limiting may prevent heads from loading.")
@ConfigEntry(path = "icon") @ConfigEntry(path = "icon")
private String icon = "SIGN"; private String icon = "SIGN";

View File

@ -12,9 +12,10 @@ warplevelrestriction: 10
# Not case sensitive! # Not case sensitive!
welcomeLine: '[Welcome]' welcomeLine: '[Welcome]'
# #
# Icon that will be displayed in Warps list. # Icon that will be displayed in Warps list. SIGN counts for any kind of sign and the type of
# It uses native Minecraft material strings, but using string 'PLAYER', it is possible to # wood used will be reflected in the panel if the server supports it.
# use player heads instead. # It uses native Minecraft material strings, but using string 'PLAYER_HEAD', it is possible to
# use player heads instead. Beware that Mojang API rate limiting may prevent heads from loading.
icon: 'SIGN' icon: 'SIGN'
# #
# This list stores GameModes in which Level addon should not work. # This list stores GameModes in which Level addon should not work.
@ -22,5 +23,3 @@ icon: 'SIGN'
# disabled-gamemodes: # disabled-gamemodes:
# - BSkyBlock # - BSkyBlock
disabled-gamemodes: [] disabled-gamemodes: []
#
uniqueId: config