Complexity reduction

This commit is contained in:
tastybento 2023-07-15 16:27:31 -07:00
parent 585f720f6f
commit a0b349ec27
2 changed files with 24 additions and 21 deletions

View File

@ -153,7 +153,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
} }
private boolean isInviteTypeTeam(UUID invitedPlayerUUID) { private boolean isInviteTypeTeam(UUID invitedPlayerUUID) {
return itc.getInvite(invitedPlayerUUID).getType().equals(Type.TEAM); return Objects.requireNonNull(itc.getInvite(invitedPlayerUUID)).getType().equals(Type.TEAM);
} }
@Override @Override

View File

@ -122,30 +122,33 @@ public class TemplatedPanel extends Panel
} }
private void fillBorder(PanelItem[][] itemArray) { private void fillBorder(PanelItem[][] itemArray) {
if (panelTemplate.border() != null) { if (panelTemplate.border() == null) {
PanelItem template = makeTemplate(panelTemplate.border()); return;
// Hard coded 6 }
for (int i = 0; i < 6; i++) { PanelItem template = makeTemplate(panelTemplate.border());
if (i == 0 || i == 5) { int numRows = itemArray.length;
// Fill first and last row completely with border. int numCols = itemArray[0].length;
for (int k = 0; k < 9; k++) {
if (itemArray[i][k] == null) { for (int i = 0; i < numRows; i++) {
itemArray[i][k] = template; if (i == 0 || i == numRows - 1) {
} // Fill first and last row completely with border.
} for (int k = 0; k < numCols; k++) {
} else { if (itemArray[i][k] == null) {
// Fill first and last element in row with border. itemArray[i][k] = template;
if (itemArray[i][0] == null) {
itemArray[i][0] = template;
}
if (itemArray[i][8] == null) {
itemArray[i][8] = template;
} }
} }
} else {
// Fill first and last element in row with border.
if (itemArray[i][0] == null) {
itemArray[i][0] = template;
}
if (itemArray[i][numCols - 1] == null) {
itemArray[i][numCols - 1] = template;
}
} }
panelTemplate.forcedRows()[0] = true;
panelTemplate.forcedRows()[5] = true;
} }
panelTemplate.forcedRows()[0] = true;
panelTemplate.forcedRows()[numRows - 1] = true;
} }
private void fillBackground(PanelItem[][] itemArray) { private void fillBackground(PanelItem[][] itemArray) {