Changes some sign coloring and adds some missing info to the readme

Makes the Disconnected message red
Makes the highlighting characters (><) white when cycling stargate destinations
Moves markPortalWithInvalidGate to PortalSignDrawer
Adds missing translation strings for reloaded and signInvalidGate to the readme
Moves some extra spacing around the >< characters
This commit is contained in:
Kristian Knarvik 2021-10-29 16:05:23 +02:00
parent f52ba79ae9
commit 5d84e1d78a
3 changed files with 37 additions and 25 deletions

View File

@ -309,6 +309,7 @@ invalidMsg=Invalid Destination
blockMsg=Destination Blocked
destEmpty=Destination List Empty
denyMsg=Access Denied
reloaded=Stargate Reloaded
ecoDeduct=Deducted %cost%
ecoRefund=Refunded %cost%
@ -332,6 +333,7 @@ signRightClick=Right click
signToUse=to use gate
signRandom=Random
signDisconnected=Disconnected
signInvalidGate=Invalid gate
bungeeDisabled=BungeeCord support is disabled.
bungeeDeny=You do not have permission to create BungeeCord gates.
@ -376,6 +378,13 @@ bungeeSign=Teleport to
- Adds missing permissions to plugin.yml and simplifies permission checks by specifying default values for child
permissions
- Renames stargate.reload to stargate.admin.reload to maintain consistency
- Marks stargates which cannot be loaded because of the gate layout not having been loaded
- Uses white for the "-" characters on the side of each stargate name when drawing signs to increase readability
- Uses white to mark the selected destination when cycling through stargate destinations
- Uses dark red to mark portals which are inactive (missing destination or invalid gate type)
- Re-draws signs on startup in case they change
- Fixes some bugs preventing changing the portal-open block on the fly
- Adds a translate-able string for when the plugin has been reloaded
#### \[Version 0.8.0.3] PseudoKnight fork

View File

@ -13,6 +13,9 @@ import org.bukkit.block.Sign;
public class PortalSignDrawer {
private final Portal portal;
private final static ChatColor highlightColor = ChatColor.WHITE;
private final static ChatColor errorColor = ChatColor.DARK_RED;
private final static ChatColor freeColor = ChatColor.DARK_GREEN;
/**
* Instantiates a new portal sign drawer
@ -49,8 +52,8 @@ public class PortalSignDrawer {
for (int index = 0; index <= 3; index++) {
sign.setLine(index, "");
}
setLine(sign, 0, ChatColor.WHITE + "-" + Stargate.getGateConfig().getSignColor() +
portal.getName() + ChatColor.WHITE + "-");
setLine(sign, 0, highlightColor + "-" + Stargate.getGateConfig().getSignColor() +
portal.getName() + highlightColor + "-");
if (!portal.getPortalActivator().isActive()) {
//Default sign text
@ -115,11 +118,11 @@ public class PortalSignDrawer {
if (freeGatesGreen) {
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
setLine(sign, signLineIndex, (green ? ChatColor.DARK_GREEN : "") + ">" +
portal.getDestinationName() + (green ? ChatColor.DARK_GREEN : "") + "<");
setLine(sign, signLineIndex, (green ? freeColor : "") + ">" +
portal.getDestinationName() + (green ? freeColor : "") + "<");
} else {
setLine(sign, signLineIndex, Stargate.getGateConfig().getSignColor() + " >" +
portal.getDestinationName() + Stargate.getGateConfig().getSignColor() + "< ");
setLine(sign, signLineIndex, highlightColor + ">" + Stargate.getGateConfig().getSignColor() +
portal.getDestinationName() + highlightColor + "<");
}
}
@ -148,7 +151,7 @@ public class PortalSignDrawer {
Portal destination = PortalHandler.getByName(destinations.getDestinations().get(destinationIndex),
portal.getNetwork());
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
setLine(sign, signLineIndex, (green ? ChatColor.DARK_GREEN : "") +
setLine(sign, signLineIndex, (green ? freeColor : "") +
destinations.getDestinations().get(destinationIndex));
} else {
setLine(sign, signLineIndex, destinations.getDestinations().get(destinationIndex));
@ -199,10 +202,25 @@ public class PortalSignDrawer {
}
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
if (destination == null && !portal.getOptions().isRandom()) {
setLine(sign, 3, Stargate.getString("signDisconnected"));
setLine(sign, 3, errorColor + Stargate.getString("signDisconnected"));
} else {
setLine(sign, 3, "");
}
}
/**
* Marks a portal with an invalid gate by changing its sign and writing to the console
*
* @param portalLocation <p>The location of the portal with an invalid gate</p>
* @param gateName <p>The name of the invalid gate type</p>
* @param lineIndex <p>The index of the line the invalid portal was found at</p>
*/
public static void markPortalWithInvalidGate(PortalLocation portalLocation, String gateName, int lineIndex) {
Sign sign = (Sign) portalLocation.getSignLocation().getBlock().getState();
sign.setLine(3, errorColor + Stargate.getString("signInvalidGate"));
sign.update();
Stargate.logInfo(String.format("Gate layout on line %d does not exist [%s]", lineIndex, gateName));
}
}

View File

@ -10,9 +10,7 @@ import net.knarcraft.stargate.portal.PortalLocation;
import net.knarcraft.stargate.portal.PortalOptions;
import net.knarcraft.stargate.portal.PortalOwner;
import net.knarcraft.stargate.portal.PortalRegistry;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.block.Sign;
import java.io.BufferedWriter;
import java.io.File;
@ -20,6 +18,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import static net.knarcraft.stargate.portal.PortalSignDrawer.markPortalWithInvalidGate;
/**
* Helper class for saving and loading portal save files
*/
@ -257,19 +257,4 @@ public final class PortalFileHelper {
portal.getPortalOpener().closePortal(true);
}
/**
* Marks a portal with an invalid gate by changing its sign and writing to the console
*
* @param portalLocation <p>The location of the portal with an invalid gate</p>
* @param gateName <p>The name of the invalid gate type</p>
* @param lineIndex <p>The index of the line the invalid portal was found at</p>
*/
private static void markPortalWithInvalidGate(PortalLocation portalLocation, String gateName, int lineIndex) {
Sign sign = (Sign) portalLocation.getSignLocation().getBlock().getState();
sign.setLine(3, ChatColor.DARK_RED + Stargate.getString("signInvalidGate"));
sign.update();
Stargate.logInfo(String.format("Gate layout on line %d does not exist [%s]", lineIndex, gateName));
}
}