Improves sign drawing during portal loading

Adds "Invalid gate" to the last line of portals with an invalid or unloaded gate type
Re-draws all portals' signs on load in case some invalid portals becomes valid. This also updates any formatting
This commit is contained in:
Kristian Knarvik 2021-10-18 18:34:35 +02:00
parent 8c16ddbed5
commit f4ec5e05d6
2 changed files with 11 additions and 0 deletions

View File

@ -937,6 +937,11 @@ public class PortalHandler {
Stargate.logger.info(String.format("%s{%s} Loaded %d stargates with %d set as always-on",
Stargate.getString("prefix"), world.getName(), portalCounts.getSecondValue(),
portalCounts.getFirstValue()));
//Re-draw the signs in case a bug in the config prevented the portal from loading and has been fixed since
for (Portal portal : allPortals) {
portal.drawSign();
}
return true;
} catch (Exception e) {
Stargate.logger.log(Level.SEVERE, "Exception while reading stargates from " + database.getName() + ": " + lineIndex);
@ -962,6 +967,11 @@ public class PortalHandler {
portalLocation.setTopLeft(new BlockLocation(world, portalData[6]));
Gate gate = GateHandler.getGateByName(portalData[7]);
if (gate == null) {
//Mark the sign as invalid to reduce some player confusion
Sign sign = (Sign) portalLocation.getSignLocation().getBlock().getState();
Stargate.setLine(sign, 3, Stargate.getString("signInvalidGate"));
sign.update();
Stargate.logger.info(Stargate.getString("prefix") + "Gate layout on line " + lineIndex +
" does not exist [" + portalData[7] + "]");
return;

View File

@ -28,6 +28,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.