Adds a highlightSignColor option and fixes some color inconsistencies
Makes all characters used for highlighting/marking use the highlighting color Adds a new config option for highlighting color Renames signColor to mainSignColor and adds the change to the config-migrations.txt file
This commit is contained in:
parent
01df8db0bf
commit
99f8a92857
@ -1,6 +1,7 @@
|
|||||||
package net.knarcraft.stargate.config;
|
package net.knarcraft.stargate.config;
|
||||||
|
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
|
import net.knarcraft.stargate.portal.PortalSignDrawer;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
@ -17,7 +18,6 @@ public final class StargateGateConfig {
|
|||||||
private boolean enableBungee = true;
|
private boolean enableBungee = true;
|
||||||
private boolean verifyPortals = true;
|
private boolean verifyPortals = true;
|
||||||
private boolean destroyExplosion = false;
|
private boolean destroyExplosion = false;
|
||||||
private ChatColor signColor;
|
|
||||||
private String defaultGateNetwork = "central";
|
private String defaultGateNetwork = "central";
|
||||||
private static final int activeTime = 10;
|
private static final int activeTime = 10;
|
||||||
private static final int openTime = 10;
|
private static final int openTime = 10;
|
||||||
@ -121,17 +121,6 @@ public final class StargateGateConfig {
|
|||||||
return destroyExplosion;
|
return destroyExplosion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the color to use for drawing signs
|
|
||||||
*
|
|
||||||
* <p>Highlighting may use other colors. This is just the base color for portal names and such.</p>
|
|
||||||
*
|
|
||||||
* @return <p>The color to use for drawing signs</p>
|
|
||||||
*/
|
|
||||||
public ChatColor getSignColor() {
|
|
||||||
return signColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default portal network to use if no other network is given
|
* Gets the default portal network to use if no other network is given
|
||||||
*
|
*
|
||||||
@ -163,24 +152,26 @@ public final class StargateGateConfig {
|
|||||||
//Cosmetic
|
//Cosmetic
|
||||||
sortNetworkDestinations = newConfig.getBoolean("gates.cosmetic.sortNetworkDestinations");
|
sortNetworkDestinations = newConfig.getBoolean("gates.cosmetic.sortNetworkDestinations");
|
||||||
rememberDestination = newConfig.getBoolean("gates.cosmetic.rememberDestination");
|
rememberDestination = newConfig.getBoolean("gates.cosmetic.rememberDestination");
|
||||||
loadSignColor(newConfig.getString("gates.cosmetic.signColor"));
|
loadSignColor(newConfig.getString("gates.cosmetic.mainSignColor"),
|
||||||
|
newConfig.getString("gates.cosmetic.highlightSignColor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the correct sign color given a sign color string
|
* Loads the correct sign color given a sign color string
|
||||||
*
|
*
|
||||||
* @param signColor <p>A string representing a sign color</p>
|
* @param mainSignColor <p>A string representing the main sign color</p>
|
||||||
*/
|
*/
|
||||||
private void loadSignColor(String signColor) {
|
private void loadSignColor(String mainSignColor, String highlightSignColor) {
|
||||||
if (signColor != null) {
|
if (mainSignColor != null) {
|
||||||
try {
|
try {
|
||||||
this.signColor = ChatColor.valueOf(signColor.toUpperCase());
|
PortalSignDrawer.setColors(ChatColor.valueOf(mainSignColor.toUpperCase()),
|
||||||
|
ChatColor.valueOf(highlightSignColor.toUpperCase()));
|
||||||
return;
|
return;
|
||||||
} catch (IllegalArgumentException | NullPointerException ignored) {
|
} catch (IllegalArgumentException | NullPointerException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK");
|
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE");
|
||||||
this.signColor = ChatColor.BLACK;
|
PortalSignDrawer.setColors(ChatColor.BLACK, ChatColor.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,10 @@ import org.bukkit.block.Sign;
|
|||||||
public class PortalSignDrawer {
|
public class PortalSignDrawer {
|
||||||
|
|
||||||
private final Portal portal;
|
private final Portal portal;
|
||||||
private final static ChatColor highlightColor = ChatColor.WHITE;
|
|
||||||
private final static ChatColor errorColor = ChatColor.DARK_RED;
|
private final static ChatColor errorColor = ChatColor.DARK_RED;
|
||||||
private final static ChatColor freeColor = ChatColor.DARK_GREEN;
|
private final static ChatColor freeColor = ChatColor.DARK_GREEN;
|
||||||
|
private static ChatColor mainColor;
|
||||||
|
private static ChatColor highlightColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new portal sign drawer
|
* Instantiates a new portal sign drawer
|
||||||
@ -26,6 +27,20 @@ public class PortalSignDrawer {
|
|||||||
this.portal = portal;
|
this.portal = portal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the main sign color
|
||||||
|
*
|
||||||
|
* <p>The main sign color is used for most text on the sign, while the highlighting color is used for the markings
|
||||||
|
* around portal names and network names ('>','<','-',')','(')</p>
|
||||||
|
*
|
||||||
|
* @param newMainColor <p>The new main sign color</p>
|
||||||
|
* @param newHighlightColor <p>The new highlight color</p>
|
||||||
|
*/
|
||||||
|
public static void setColors(ChatColor newMainColor, ChatColor newHighlightColor) {
|
||||||
|
mainColor = newMainColor;
|
||||||
|
highlightColor = newHighlightColor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the sign of the portal this sign drawer is responsible for
|
* Draws the sign of the portal this sign drawer is responsible for
|
||||||
*/
|
*/
|
||||||
@ -47,12 +62,12 @@ public class PortalSignDrawer {
|
|||||||
*
|
*
|
||||||
* @param sign <p>The sign re-draw</p>
|
* @param sign <p>The sign re-draw</p>
|
||||||
*/
|
*/
|
||||||
public void drawSign(Sign sign) {
|
private void drawSign(Sign sign) {
|
||||||
//Clear sign
|
//Clear sign
|
||||||
for (int index = 0; index <= 3; index++) {
|
for (int index = 0; index <= 3; index++) {
|
||||||
sign.setLine(index, "");
|
sign.setLine(index, "");
|
||||||
}
|
}
|
||||||
setLine(sign, 0, highlightColor + "-" + Stargate.getGateConfig().getSignColor() +
|
setLine(sign, 0, highlightColor + "-" + mainColor +
|
||||||
portal.getName() + highlightColor + "-");
|
portal.getName() + highlightColor + "-");
|
||||||
|
|
||||||
if (!portal.getPortalActivator().isActive()) {
|
if (!portal.getPortalActivator().isActive()) {
|
||||||
@ -118,11 +133,12 @@ public class PortalSignDrawer {
|
|||||||
if (freeGatesGreen) {
|
if (freeGatesGreen) {
|
||||||
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
|
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
|
||||||
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
|
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
|
||||||
setLine(sign, signLineIndex, (green ? freeColor : "") + ">" +
|
ChatColor nameColor = (green ? freeColor : highlightColor);
|
||||||
portal.getDestinationName() + (green ? freeColor : "") + "<");
|
setLine(sign, signLineIndex, nameColor + ">" + (green ? freeColor : mainColor) +
|
||||||
|
portal.getDestinationName() + nameColor + "<");
|
||||||
} else {
|
} else {
|
||||||
setLine(sign, signLineIndex, highlightColor + ">" + Stargate.getGateConfig().getSignColor() +
|
setLine(sign, signLineIndex, highlightColor + ">" + mainColor + portal.getDestinationName() +
|
||||||
portal.getDestinationName() + highlightColor + "<");
|
highlightColor + "<");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +150,7 @@ public class PortalSignDrawer {
|
|||||||
* @param text <p>The new text on the sign</p>
|
* @param text <p>The new text on the sign</p>
|
||||||
*/
|
*/
|
||||||
public void setLine(Sign sign, int index, String text) {
|
public void setLine(Sign sign, int index, String text) {
|
||||||
sign.setLine(index, Stargate.getGateConfig().getSignColor() + text);
|
sign.setLine(index, mainColor + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,14 +163,13 @@ public class PortalSignDrawer {
|
|||||||
*/
|
*/
|
||||||
private void drawNetworkSignLine(boolean freeGatesGreen, Sign sign, int signLineIndex, int destinationIndex) {
|
private void drawNetworkSignLine(boolean freeGatesGreen, Sign sign, int signLineIndex, int destinationIndex) {
|
||||||
PortalActivator destinations = portal.getPortalActivator();
|
PortalActivator destinations = portal.getPortalActivator();
|
||||||
|
String destinationName = destinations.getDestinations().get(destinationIndex);
|
||||||
if (freeGatesGreen) {
|
if (freeGatesGreen) {
|
||||||
Portal destination = PortalHandler.getByName(destinations.getDestinations().get(destinationIndex),
|
Portal destination = PortalHandler.getByName(destinationName, portal.getNetwork());
|
||||||
portal.getNetwork());
|
|
||||||
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
|
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
|
||||||
setLine(sign, signLineIndex, (green ? freeColor : "") +
|
setLine(sign, signLineIndex, (green ? freeColor : mainColor) + destinationName);
|
||||||
destinations.getDestinations().get(destinationIndex));
|
|
||||||
} else {
|
} else {
|
||||||
setLine(sign, signLineIndex, destinations.getDestinations().get(destinationIndex));
|
setLine(sign, signLineIndex, mainColor + destinationName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,8 +180,8 @@ public class PortalSignDrawer {
|
|||||||
*/
|
*/
|
||||||
private void drawBungeeSign(Sign sign) {
|
private void drawBungeeSign(Sign sign) {
|
||||||
setLine(sign, 1, Stargate.getString("bungeeSign"));
|
setLine(sign, 1, Stargate.getString("bungeeSign"));
|
||||||
setLine(sign, 2, ">" + portal.getDestinationName() + "<");
|
setLine(sign, 2, highlightColor + ">" + mainColor + portal.getDestinationName() + highlightColor + "<");
|
||||||
setLine(sign, 3, "[" + portal.getNetwork() + "]");
|
setLine(sign, 3, highlightColor + "[" + mainColor + portal.getNetwork() + highlightColor + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +193,7 @@ public class PortalSignDrawer {
|
|||||||
setLine(sign, 1, Stargate.getString("signRightClick"));
|
setLine(sign, 1, Stargate.getString("signRightClick"));
|
||||||
setLine(sign, 2, Stargate.getString("signToUse"));
|
setLine(sign, 2, Stargate.getString("signToUse"));
|
||||||
if (!portal.getOptions().isNoNetwork()) {
|
if (!portal.getOptions().isNoNetwork()) {
|
||||||
setLine(sign, 3, "(" + portal.getNetwork() + ")");
|
setLine(sign, 3, highlightColor + "(" + mainColor + portal.getNetwork() + highlightColor + ")");
|
||||||
} else {
|
} else {
|
||||||
setLine(sign, 3, "");
|
setLine(sign, 3, "");
|
||||||
}
|
}
|
||||||
@ -190,15 +205,14 @@ public class PortalSignDrawer {
|
|||||||
* @param sign <p>The sign to re-draw</p>
|
* @param sign <p>The sign to re-draw</p>
|
||||||
*/
|
*/
|
||||||
private void drawFixedSign(Sign sign) {
|
private void drawFixedSign(Sign sign) {
|
||||||
if (portal.getOptions().isRandom()) {
|
String destinationName = portal.getOptions().isRandom() ? Stargate.getString("signRandom") :
|
||||||
setLine(sign, 1, ">" + Stargate.getString("signRandom") + "<");
|
portal.getDestinationName();
|
||||||
} else {
|
setLine(sign, 1, highlightColor + ">" + mainColor + destinationName + highlightColor + "<");
|
||||||
setLine(sign, 1, ">" + portal.getDestinationName() + "<");
|
|
||||||
}
|
|
||||||
if (portal.getOptions().isNoNetwork()) {
|
if (portal.getOptions().isNoNetwork()) {
|
||||||
setLine(sign, 2, "");
|
setLine(sign, 2, "");
|
||||||
} else {
|
} else {
|
||||||
setLine(sign, 2, "(" + portal.getNetwork() + ")");
|
setLine(sign, 2, highlightColor + "(" + mainColor + portal.getNetwork() + highlightColor + ")");
|
||||||
}
|
}
|
||||||
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
|
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
|
||||||
if (destination == null && !portal.getOptions().isRandom()) {
|
if (destination == null && !portal.getOptions().isRandom()) {
|
||||||
|
@ -13,6 +13,7 @@ protectEntrance=gates.integrity.protectEntrance
|
|||||||
enableBungee=gates.functionality.enableBungee
|
enableBungee=gates.functionality.enableBungee
|
||||||
verifyPortals=gates.integrity.verifyPortals
|
verifyPortals=gates.integrity.verifyPortals
|
||||||
signColor=gates.cosmetic.signColor
|
signColor=gates.cosmetic.signColor
|
||||||
|
gates.cosmetic.signColor=gates.cosmetic.mainSignColor
|
||||||
debug=debugging.debug
|
debug=debugging.debug
|
||||||
permdebug=debugging.permissionDebug
|
permdebug=debugging.permissionDebug
|
||||||
useiconomy=economy.useEconomy
|
useiconomy=economy.useEconomy
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
# handleVehicles - Whether to allow vehicles through gates
|
# handleVehicles - Whether to allow vehicles through gates
|
||||||
# sortNetworkDestinations - Whether to sort network lists alphabetically
|
# sortNetworkDestinations - Whether to sort network lists alphabetically
|
||||||
# protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using destroyable open/closed material)
|
# protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using destroyable open/closed material)
|
||||||
# signColor - The color used for drawing signs (Default: BLACK).
|
# mainSignColor - The color used for drawing signs (Default: BLACK).
|
||||||
|
# highlightSignColor - The color used for sign markings (Default: WHITE)
|
||||||
# verifyPortals - Whether all the non-sign blocks are checked to match the gate layout when a stargate is loaded.
|
# verifyPortals - Whether all the non-sign blocks are checked to match the gate layout when a stargate is loaded.
|
||||||
# I------------I-------------I #
|
# I------------I-------------I #
|
||||||
# stargate economy options #
|
# stargate economy options #
|
||||||
@ -39,7 +40,8 @@ gates:
|
|||||||
cosmetic:
|
cosmetic:
|
||||||
rememberDestination: false
|
rememberDestination: false
|
||||||
sortNetworkDestinations: false
|
sortNetworkDestinations: false
|
||||||
signColor: BLACK
|
mainSignColor: BLACK
|
||||||
|
highlightSignColor: WHITE
|
||||||
integrity:
|
integrity:
|
||||||
destroyedByExplosion: false
|
destroyedByExplosion: false
|
||||||
verifyPortals: false
|
verifyPortals: false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user