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
|
// Disable
|
||||||
this.logError("WelcomeWarp settings could not load! Addon disabled.");
|
this.logError("WelcomeWarp settings could not load! Addon disabled.");
|
||||||
this.setState(State.DISABLED);
|
this.setState(State.DISABLED);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
settingsConfig.saveConfigObject(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class WarpPanelManager {
|
||||||
|
|
||||||
private PanelItem getPanelItem(World world, UUID warpOwner) {
|
private PanelItem getPanelItem(World world, UUID warpOwner) {
|
||||||
PanelItemBuilder pib = new PanelItemBuilder()
|
PanelItemBuilder pib = new PanelItemBuilder()
|
||||||
.name(addon.getPlugin().getPlayers().getName(warpOwner))
|
.name(addon.getSettings().getNameFormat() + addon.getPlugin().getPlayers().getName(warpOwner))
|
||||||
.description(getSign(world, warpOwner))
|
.description(getSign(world, warpOwner))
|
||||||
.clickHandler((panel, clicker, click, slot) -> { {
|
.clickHandler((panel, clicker, click, slot) -> { {
|
||||||
clicker.closeInventory();
|
clicker.closeInventory();
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class WarpSignsManager {
|
||||||
*/
|
*/
|
||||||
public boolean addWarp(final UUID playerUUID, final Location loc) {
|
public boolean addWarp(final UUID playerUUID, final Location loc) {
|
||||||
// Do not allow null players to set warps
|
// Do not allow null players to set warps
|
||||||
if (playerUUID == null) {
|
if (playerUUID == null || loc == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check for warps placed in a location where there was a warp before
|
// Check for warps placed in a location where there was a warp before
|
||||||
|
@ -148,7 +148,7 @@ public class WarpSignsManager {
|
||||||
}
|
}
|
||||||
// Fire event
|
// Fire event
|
||||||
WarpListEvent event = new WarpListEvent(addon, list);
|
WarpListEvent event = new WarpListEvent(addon, list);
|
||||||
addon.getServer().getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
// Get the result of any changes by listeners
|
// Get the result of any changes by listeners
|
||||||
list = event.getWarps();
|
list = event.getWarps();
|
||||||
return list;
|
return list;
|
||||||
|
@ -268,10 +268,13 @@ public class WarpSignsManager {
|
||||||
result.remove(0);
|
result.remove(0);
|
||||||
// Remove any trailing blank lines
|
// Remove any trailing blank lines
|
||||||
result.removeIf(String::isEmpty);
|
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
|
// Get the sign type
|
||||||
|
|
||||||
String prefix = this.plugin.getIWM().getAddon(world).map(
|
String prefix = plugin.getIWM().getAddon(world).map(Addon::getPermissionPrefix).orElse("");
|
||||||
Addon::getPermissionPrefix).orElse("");
|
|
||||||
|
|
||||||
Material icon;
|
Material icon;
|
||||||
|
|
||||||
|
@ -394,7 +397,7 @@ public class WarpSignsManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Island island = addon.getPlugin().getIslands().getIsland(world, owner);
|
Island island = addon.getIslands().getIsland(world, owner);
|
||||||
boolean pvp = false;
|
boolean pvp = false;
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
// Check for PVP
|
// Check for PVP
|
||||||
|
@ -421,25 +424,25 @@ public class WarpSignsManager {
|
||||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||||
Location oneDown = b.getRelative(directionFacing).getRelative(BlockFace.DOWN).getLocation();
|
Location oneDown = b.getRelative(directionFacing).getRelative(BlockFace.DOWN).getLocation();
|
||||||
if ((plugin.getIslands().isSafeLocation(inFront))) {
|
if ((plugin.getIslands().isSafeLocation(inFront))) {
|
||||||
addon.getWarpSignsManager().warpPlayer(user, inFront, owner, directionFacing, pvp);
|
warpPlayer(user, inFront, owner, directionFacing, pvp);
|
||||||
return;
|
return;
|
||||||
} else if (plugin.getIslands().isSafeLocation(oneDown)) {
|
} else if (plugin.getIslands().isSafeLocation(oneDown)) {
|
||||||
// Try one block down if this is a wall sign
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
} else if (b.getType().name().contains("SIGN")) {
|
} else if (b.getType().name().contains("SIGN")) {
|
||||||
org.bukkit.block.data.type.Sign s = (org.bukkit.block.data.type.Sign) b.getBlockData();
|
org.bukkit.block.data.type.Sign s = (org.bukkit.block.data.type.Sign) b.getBlockData();
|
||||||
BlockFace directionFacing = s.getRotation();
|
BlockFace directionFacing = s.getRotation();
|
||||||
Location inFront = b.getRelative(directionFacing).getLocation();
|
Location inFront = b.getRelative(directionFacing).getLocation();
|
||||||
if ((plugin.getIslands().isSafeLocation(inFront))) {
|
if ((addon.getIslands().isSafeLocation(inFront))) {
|
||||||
addon.getWarpSignsManager().warpPlayer(user, inFront, owner, directionFacing, pvp);
|
warpPlayer(user, inFront, owner, directionFacing, pvp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Warp has been removed
|
// Warp has been removed
|
||||||
user.sendMessage("warps.error.does-not-exist");
|
user.sendMessage("warps.error.does-not-exist");
|
||||||
addon.getWarpSignsManager().removeWarp(warpSpot);
|
removeWarp(warpSpot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(plugin.getIslands().isSafeLocation(warpSpot))) {
|
if (!(plugin.getIslands().isSafeLocation(warpSpot))) {
|
||||||
|
|
|
@ -44,7 +44,19 @@ public class Settings implements ConfigObject
|
||||||
@ConfigComment(" - BSkyBlock")
|
@ConfigComment(" - BSkyBlock")
|
||||||
@ConfigEntry(path = "disabled-gamemodes")
|
@ConfigEntry(path = "disabled-gamemodes")
|
||||||
private Set<String> disabledGameModes = new HashSet<>();
|
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
|
// Section: Constructor
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -143,4 +155,38 @@ public class Settings implements ConfigObject
|
||||||
{
|
{
|
||||||
this.icon = icon;
|
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:
|
# disabled-gamemodes:
|
||||||
# - BSkyBlock
|
# - BSkyBlock
|
||||||
disabled-gamemodes: []
|
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