Don't edit the jail signs async, as that is bad and causes #36.

This should fix the Asynchronous entity world add exception being thrown
This commit is contained in:
graywolf336 2015-01-13 01:13:22 -06:00
parent e84452bfd8
commit 84b6505ae3

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailMain;
@ -19,17 +20,21 @@ import com.graywolf336.jail.events.PrisonerTransferredEvent;
public class CellSignListener implements Listener { public class CellSignListener implements Listener {
private String lineOne, lineTwo, lineThree, lineFour; private String lineOne, lineTwo, lineThree, lineFour;
private JailMain pl;
public CellSignListener(JailMain plugin) { public CellSignListener(JailMain plugin) {
List<String> lines = plugin.getConfig().getStringList(Settings.CELLSIGNLINES.getPath()); pl = plugin;
List<String> lines = pl.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
lineOne = lines.get(0); lineOne = lines.get(0);
lineTwo = lines.get(1); lineTwo = lines.get(1);
lineThree = lines.get(2); lineThree = lines.get(2);
lineFour = lines.get(3); lineFour = lines.get(3);
} }
@EventHandler @EventHandler(ignoreCancelled=true, priority = EventPriority.MONITOR)
public void changeTheCellSigns(PrisonerTimeChangeEvent event) { public void changeTheCellSigns(final PrisonerTimeChangeEvent event) {
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
public void run() {
if (event.hasCell() && event.getCell().hasSigns()) { if (event.hasCell() && event.getCell().hasSigns()) {
HashSet<SimpleLocation> signs = event.getCell().getSigns(); HashSet<SimpleLocation> signs = event.getCell().getSigns();
String s1 = Util.replaceAllVariables(event.getPrisoner(), lineOne); String s1 = Util.replaceAllVariables(event.getPrisoner(), lineOne);
@ -53,6 +58,8 @@ public class CellSignListener implements Listener {
} }
} }
} }
});
}
@EventHandler @EventHandler
public void changeCellSignsOnJail(PrisonerJailedEvent event) { public void changeCellSignsOnJail(PrisonerJailedEvent event) {