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) {
// Return a sign panel item
return new PanelItemBuilder()
.icon(getSignIcon(world, warpOwner))
PanelItemBuilder pib = new PanelItemBuilder()
.name(addon.getPlugin().getPlayers().getName(warpOwner))
.description(getSign(world, warpOwner))
.clickHandler((panel, clicker, click, slot) -> { {
@ -39,7 +37,13 @@ public class WarpPanelManager {
addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner);
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) {

View File

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

View File

@ -30,9 +30,10 @@ public class Settings implements ConfigObject
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.")
@ConfigComment("Icon that will be displayed in Warps list. SIGN counts for any kind of sign and the type of")
@ConfigComment("wood used will be reflected in the panel if the server supports it.")
@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")
private String icon = "SIGN";

View File

@ -12,9 +12,10 @@ warplevelrestriction: 10
# 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 that will be displayed in Warps list. SIGN counts for any kind of sign and the type of
# wood used will be reflected in the panel if the server supports it.
# 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'
#
# This list stores GameModes in which Level addon should not work.
@ -22,5 +23,3 @@ icon: 'SIGN'
# disabled-gamemodes:
# - BSkyBlock
disabled-gamemodes: []
#
uniqueId: config