Update the signs on jailing, this closes #31.
This commit is contained in:
parent
6ddabe39ad
commit
3405ab100f
@ -12,6 +12,7 @@ import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerReleasedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerTimeChangeEvent;
|
||||
import com.graywolf336.jail.events.PrisonerTransferredEvent;
|
||||
@ -53,6 +54,32 @@ public class CellSignListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void changeCellSignsOnJail(PrisonerJailedEvent event) {
|
||||
if (event.hasCell() && event.getCell().hasSigns()) {
|
||||
HashSet<SimpleLocation> signs = event.getCell().getSigns();
|
||||
String s1 = Util.replaceAllVariables(event.getPrisoner(), lineOne);
|
||||
String s2 = Util.replaceAllVariables(event.getPrisoner(), lineTwo);
|
||||
String s3 = Util.replaceAllVariables(event.getPrisoner(), lineThree);
|
||||
String s4 = Util.replaceAllVariables(event.getPrisoner(), lineFour);
|
||||
|
||||
for (SimpleLocation s : signs) {
|
||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) s.getLocation().getBlock().getState();
|
||||
sign.setLine(0, s1);
|
||||
sign.setLine(1, s2);
|
||||
sign.setLine(2, s3);
|
||||
sign.setLine(3, s4);
|
||||
sign.update();
|
||||
} else {
|
||||
// Remove the sign from the cell since it isn't
|
||||
// a valid sign
|
||||
event.getCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void clearTheCellSigns(PrisonerReleasedEvent event) {
|
||||
if (event.hasCell() && event.getCell().hasSigns()) {
|
||||
|
Loading…
Reference in New Issue
Block a user