Only load lines for signs configured, fixes #61

Don't try to load line 4 when it isn't configured in the configuration,
fixes the onload IndexOutOfBoundsException.
This commit is contained in:
graywolf336
2015-05-26 16:25:02 -05:00
parent 9f6c0c4e49
commit 9b638d6360
2 changed files with 8 additions and 6 deletions

View File

@ -19,16 +19,17 @@ import com.graywolf336.jail.events.PrisonerTimeChangeEvent;
import com.graywolf336.jail.events.PrisonerTransferredEvent;
public class CellSignListener implements Listener {
private String lineOne, lineTwo, lineThree, lineFour;
private String lineOne = "", lineTwo = "", lineThree = "", lineFour = "";
private JailMain pl;
public CellSignListener(JailMain plugin) {
pl = plugin;
List<String> lines = pl.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
lineOne = lines.get(0);
lineTwo = lines.get(1);
lineThree = lines.get(2);
lineFour = lines.get(3);
if(lines.size() >= 1) lineOne = lines.get(0);
if(lines.size() >= 2) lineTwo = lines.get(1);
if(lines.size() >= 3) lineThree = lines.get(2);
if(lines.size() >= 4) lineFour = lines.get(3);
}
@EventHandler(ignoreCancelled=true, priority = EventPriority.MONITOR)