Enabled formatting of warp sign text
https://github.com/BentoBoxWorld/Warps/issues/48
This commit is contained in:
parent
675f5791bd
commit
bbc748aae3
|
@ -155,7 +155,9 @@ public class Warp extends Addon {
|
|||
// Disable
|
||||
this.logError("WelcomeWarp settings could not load! Addon disabled.");
|
||||
this.setState(State.DISABLED);
|
||||
return;
|
||||
}
|
||||
settingsConfig.saveConfigObject(settings);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class WarpPanelManager {
|
|||
|
||||
private PanelItem getPanelItem(World world, UUID warpOwner) {
|
||||
PanelItemBuilder pib = new PanelItemBuilder()
|
||||
.name(addon.getPlugin().getPlayers().getName(warpOwner))
|
||||
.name(addon.getSettings().getNameFormat() + addon.getPlugin().getPlayers().getName(warpOwner))
|
||||
.description(getSign(world, warpOwner))
|
||||
.clickHandler((panel, clicker, click, slot) -> { {
|
||||
clicker.closeInventory();
|
||||
|
|
|
@ -86,7 +86,7 @@ public class WarpSignsManager {
|
|||
*/
|
||||
public boolean addWarp(final UUID playerUUID, final Location loc) {
|
||||
// Do not allow null players to set warps
|
||||
if (playerUUID == null) {
|
||||
if (playerUUID == null || loc == null) {
|
||||
return false;
|
||||
}
|
||||
// Check for warps placed in a location where there was a warp before
|
||||
|
@ -148,7 +148,7 @@ public class WarpSignsManager {
|
|||
}
|
||||
// Fire event
|
||||
WarpListEvent event = new WarpListEvent(addon, list);
|
||||
addon.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
// Get the result of any changes by listeners
|
||||
list = event.getWarps();
|
||||
return list;
|
||||
|
@ -268,10 +268,13 @@ public class WarpSignsManager {
|
|||
result.remove(0);
|
||||
// Remove any trailing blank lines
|
||||
result.removeIf(String::isEmpty);
|
||||
// Set the initial color per lore setting
|
||||
for (int i = 0; i< result.size(); i++) {
|
||||
result.set(i, ChatColor.translateAlternateColorCodes('&', addon.getSettings().getLoreFormat()) + result.get(i));
|
||||
}
|
||||
// Get the sign type
|
||||
|
||||
String prefix = this.plugin.getIWM().getAddon(world).map(
|
||||
Addon::getPermissionPrefix).orElse("");
|
||||
String prefix = plugin.getIWM().getAddon(world).map(Addon::getPermissionPrefix).orElse("");
|
||||
|
||||
Material icon;
|
||||
|
||||
|
@ -394,7 +397,7 @@ public class WarpSignsManager {
|
|||
return;
|
||||
}
|
||||
|
||||
Island island = addon.getPlugin().getIslands().getIsland(world, owner);
|
||||
Island island = addon.getIslands().getIsland(world, owner);
|
||||
boolean pvp = false;
|
||||
if (island != null) {
|
||||
// Check for PVP
|
||||
|
@ -421,25 +424,25 @@ public class WarpSignsManager {
|
|||
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||
Location oneDown = b.getRelative(directionFacing).getRelative(BlockFace.DOWN).getLocation();
|
||||
if ((plugin.getIslands().isSafeLocation(inFront))) {
|
||||
addon.getWarpSignsManager().warpPlayer(user, inFront, owner, directionFacing, pvp);
|
||||
warpPlayer(user, inFront, owner, directionFacing, pvp);
|
||||
return;
|
||||
} else if (plugin.getIslands().isSafeLocation(oneDown)) {
|
||||
// Try one block down if this is a wall sign
|
||||
addon.getWarpSignsManager().warpPlayer(user, oneDown, owner, directionFacing, pvp);
|
||||
warpPlayer(user, oneDown, owner, directionFacing, pvp);
|
||||
return;
|
||||
}
|
||||
} else if (b.getType().name().contains("SIGN")) {
|
||||
org.bukkit.block.data.type.Sign s = (org.bukkit.block.data.type.Sign) b.getBlockData();
|
||||
BlockFace directionFacing = s.getRotation();
|
||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||
if ((plugin.getIslands().isSafeLocation(inFront))) {
|
||||
addon.getWarpSignsManager().warpPlayer(user, inFront, owner, directionFacing, pvp);
|
||||
if ((addon.getIslands().isSafeLocation(inFront))) {
|
||||
warpPlayer(user, inFront, owner, directionFacing, pvp);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Warp has been removed
|
||||
user.sendMessage("warps.error.does-not-exist");
|
||||
addon.getWarpSignsManager().removeWarp(warpSpot);
|
||||
removeWarp(warpSpot);
|
||||
return;
|
||||
}
|
||||
if (!(plugin.getIslands().isSafeLocation(warpSpot))) {
|
||||
|
|
|
@ -44,7 +44,19 @@ public class Settings implements ConfigObject
|
|||
@ConfigComment(" - BSkyBlock")
|
||||
@ConfigEntry(path = "disabled-gamemodes")
|
||||
private Set<String> disabledGameModes = new HashSet<>();
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Warp panel name formatting.")
|
||||
@ConfigComment("Example: &c will make names red. &f is white")
|
||||
@ConfigEntry(path = "name-format")
|
||||
private String nameFormat = "&f";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Warp panel default lore formatting.")
|
||||
@ConfigComment("Example: &c will make lore red. &f is white")
|
||||
@ConfigEntry(path = "lore-format")
|
||||
private String loreFormat = "&f";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Constructor
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -143,4 +155,38 @@ public class Settings implements ConfigObject
|
|||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the nameFormat
|
||||
*/
|
||||
public String getNameFormat() {
|
||||
return nameFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param nameFormat the nameFormat to set
|
||||
*/
|
||||
public void setNameFormat(String nameFormat) {
|
||||
this.nameFormat = nameFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the loreFormat
|
||||
*/
|
||||
public String getLoreFormat() {
|
||||
return loreFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param loreFormat the loreFormat to set
|
||||
*/
|
||||
public void setLoreFormat(String loreFormat) {
|
||||
this.loreFormat = loreFormat;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,3 +23,11 @@ icon: 'SIGN'
|
|||
# disabled-gamemodes:
|
||||
# - BSkyBlock
|
||||
disabled-gamemodes: []
|
||||
#
|
||||
# Warp panel name formatting.
|
||||
# Example: &c will make names red, &f is white
|
||||
name-format: &f
|
||||
#
|
||||
# Warp panel default lore formatting.
|
||||
# Example: &c will make lore red. &f is white
|
||||
lore-format: &f
|
||||
|
|
Loading…
Reference in New Issue