/** * Iterate through the signs and return the text if only one is found. * * @param foundSigns * @return * @throws MoreThanOneSignFoundException * @throws NoMultiverseSignFoundException */ private String processSigns(List<Sign> foundSigns, Player player) throws MoreThanOneSignFoundException, NoMultiverseSignFoundException { Sign foundSign = null; Sign legacySign = null; Sign normalSign = null; for (Sign s : foundSigns) { if (this.getSignStatus(s) == SignStatus.NetherPortalSign) { if (foundSign != null) { throw new MoreThanOneSignFoundException(); } foundSign = s; } else if (foundSign == null && this.getSignStatus(s) == SignStatus.Legacy) { // Found an old sign if (legacySign != null) { throw new MoreThanOneSignFoundException(); } legacySign = s; } else if (foundSign == null && this.getSignStatus(s) == SignStatus.SignPortal) { // Found a normal signPortal if (normalSign != null) { throw new MoreThanOneSignFoundException(); } normalSign = s; } } if (foundSign == null && legacySign == null && normalSign == null) { throw new NoMultiverseSignFoundException(); } if (foundSign != null) { this.invalidateOtherSigns(foundSign, foundSigns); return foundSign.getLine(2); } if (legacySign != null) { if (this.plugin .getCore() .getMVPerms() .hasPermission(player, "multiverse.signportal.validate", true)) { this.plugin.log(Level.FINE, "Migrating Legacy Sign"); legacySign.setLine(1, SignTools.setColor(legacySign.getLine(1), ChatColor.DARK_BLUE)); legacySign.update(true); this.invalidateOtherSigns(legacySign, foundSigns); return legacySign.getLine(2); } } if (normalSign != null) { this.plugin.log(Level.FINE, "Migrating Normal Sign"); normalSign.setLine(1, SignTools.setColor(normalSign.getLine(1), ChatColor.DARK_BLUE)); normalSign.update(true); return normalSign.getLine(2); } throw new NoMultiverseSignFoundException(); }
public String processSign(Sign sign) { if (SignTools.isMVSign(sign.getLine(1), ChatColor.DARK_GREEN)) { this.plugin.log(Level.FINER, "Found a MV Sign"); return sign.getLine(2) + sign.getLine(3); } return null; }
private void invalidateOtherSigns(Sign sign, List<Sign> foundSigns) { for (Sign s : foundSigns) { if (!s.equals(sign)) { s.setLine(1, SignTools.setColor(s.getLine(1), ChatColor.DARK_RED)); s.update(true); } } }
public SignStatus getSignStatus(Sign sign) { if (SignTools.isMVSign(sign.getLine(1), ChatColor.DARK_GREEN)) { this.plugin.log(Level.FINER, "Found a MV Sign (Sign Portal)"); return SignStatus.SignPortal; } if (SignTools.isMVSign(sign.getLine(1), ChatColor.DARK_BLUE)) { this.plugin.log(Level.FINER, "Found a MV Sign (Nether Portal that has a Sign)"); return SignStatus.NetherPortalSign; } if (SignTools.isMVSign(sign.getLine(1), ChatColor.DARK_RED)) { this.plugin.log(Level.FINER, "Found a MV Sign (Disabled)"); return SignStatus.Disabled; } if (SignTools.isMVSign(sign.getLine(1), null)) { this.plugin.log(Level.FINER, "Found a MV Sign (Legacy)"); return SignStatus.Legacy; } return SignStatus.NotASignPortal; }
public void activateSignPortal(Player player, String type, Sign sign) { if (this.plugin .getCore() .getMVPerms() .hasPermission(player, "multiverse.signportal.validate", true)) { // Do 2-stage validation ChatColor colorToChange = ChatColor.DARK_GREEN; if (SignTools.isMVSign("mv", ChatColor.GREEN)) { colorToChange = ChatColor.DARK_BLUE; player.sendMessage("This vanilla sign portal has been " + ChatColor.GREEN + " Validated!"); } else { player.sendMessage("This MV sign portal has been " + ChatColor.GREEN + " Validated!"); } sign.setLine(1, SignTools.setColor(sign.getLine(1), colorToChange)); sign.update(true); } else { player.sendMessage( "Sorry you don't have permission to activate this " + type + ChatColor.WHITE + " SignPortal."); } }