Fix some spacing issues introduced by the last commit.
This commit is contained in:
parent
81da8ddb59
commit
85e1106b42
@ -96,22 +96,22 @@ public class Util {
|
||||
public static String getColorfulMessage(String message) {
|
||||
return message.replaceAll("(?i)&([0-9abcdefklmnor])", "\u00A7$1");
|
||||
}
|
||||
|
||||
|
||||
/** Returns a message with all the possible variables replaced. */
|
||||
public static String replaceAllVariables(Prisoner p, String msg) {
|
||||
msg = msg.replaceAll("%player%", p.getLastKnownName());
|
||||
msg = msg.replaceAll("%uuid%", p.getUUID().toString());
|
||||
msg = msg.replaceAll("%reason%", p.getReason());
|
||||
msg = msg.replaceAll("%jailer", p.getJailer());
|
||||
msg = msg.replaceAll("%afktime%", TimeUnit.MILLISECONDS.toMinutes(p.getAFKTime()) + "m");
|
||||
|
||||
if(p.getRemainingTime() >= 0) {
|
||||
msg = msg.replaceAll("%timeinminutes%", String.valueOf(p.getRemainingTimeInMinutes()));
|
||||
}else {
|
||||
msg = msg.replaceAll("%timeinminutes%", Lang.JAILEDFOREVERSIGN.get());
|
||||
}
|
||||
|
||||
return getColorfulMessage(msg);
|
||||
msg = msg.replaceAll("%player%", p.getLastKnownName());
|
||||
msg = msg.replaceAll("%uuid%", p.getUUID().toString());
|
||||
msg = msg.replaceAll("%reason%", p.getReason());
|
||||
msg = msg.replaceAll("%jailer", p.getJailer());
|
||||
msg = msg.replaceAll("%afktime%", TimeUnit.MILLISECONDS.toMinutes(p.getAFKTime()) + " mins");
|
||||
|
||||
if(p.getRemainingTime() >= 0) {
|
||||
msg = msg.replaceAll("%timeinminutes%", String.valueOf(p.getRemainingTimeInMinutes()));
|
||||
}else {
|
||||
msg = msg.replaceAll("%timeinminutes%", Lang.JAILEDFOREVERSIGN.get());
|
||||
}
|
||||
|
||||
return getColorfulMessage(msg);
|
||||
}
|
||||
|
||||
/** Returns the wand used throughout the different creation steps. */
|
||||
|
@ -17,106 +17,106 @@ import com.graywolf336.jail.events.PrisonerTimeChangeEvent;
|
||||
import com.graywolf336.jail.events.PrisonerTransferredEvent;
|
||||
|
||||
public class CellSignListener implements Listener {
|
||||
private String lineOne, lineTwo, lineThree, lineFour;
|
||||
|
||||
public CellSignListener(JailMain plugin) {
|
||||
List<String> lines = plugin.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
|
||||
lineOne = lines.get(0);
|
||||
lineTwo = lines.get(1);
|
||||
lineThree = lines.get(2);
|
||||
lineFour = lines.get(3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private String lineOne, lineTwo, lineThree, lineFour;
|
||||
|
||||
public CellSignListener(JailMain plugin) {
|
||||
List<String> lines = plugin.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
|
||||
lineOne = lines.get(0);
|
||||
lineTwo = lines.get(1);
|
||||
lineThree = lines.get(2);
|
||||
lineFour = lines.get(3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void changeTheCellSigns(PrisonerTimeChangeEvent 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()) {
|
||||
HashSet<SimpleLocation> signs = event.getCell().getSigns();
|
||||
|
||||
for(SimpleLocation s : signs) {
|
||||
if(s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) s.getLocation().getBlock().getState();
|
||||
sign.setLine(0, "");
|
||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "");
|
||||
sign.update();
|
||||
}else {
|
||||
//Remove the sign from the cell since it isn't
|
||||
//a valid sign
|
||||
event.getCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleSignsOnTransfer(PrisonerTransferredEvent event) {
|
||||
if(event.hasOriginalCell() && event.getOriginalCell().hasSigns()) {
|
||||
HashSet<SimpleLocation> signs = event.getOriginalCell().getSigns();
|
||||
|
||||
for(SimpleLocation s : signs) {
|
||||
if(s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) s.getLocation().getBlock().getState();
|
||||
sign.setLine(0, "");
|
||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "");
|
||||
sign.update();
|
||||
}else {
|
||||
//Remove the sign from the cell since it isn't
|
||||
//a valid sign
|
||||
event.getOriginalCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(event.hasTargetCell() && event.getTargetCell().hasSigns()) {
|
||||
HashSet<SimpleLocation> signs = event.getTargetCell().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.getTargetCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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()) {
|
||||
HashSet<SimpleLocation> signs = event.getCell().getSigns();
|
||||
|
||||
for (SimpleLocation s : signs) {
|
||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) s.getLocation().getBlock().getState();
|
||||
sign.setLine(0, "");
|
||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "");
|
||||
sign.update();
|
||||
} else {
|
||||
// Remove the sign from the cell since it isn't
|
||||
// a valid sign
|
||||
event.getCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleSignsOnTransfer(PrisonerTransferredEvent event) {
|
||||
if (event.hasOriginalCell() && event.getOriginalCell().hasSigns()) {
|
||||
HashSet<SimpleLocation> signs = event.getOriginalCell().getSigns();
|
||||
|
||||
for (SimpleLocation s : signs) {
|
||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) s.getLocation().getBlock().getState();
|
||||
sign.setLine(0, "");
|
||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "");
|
||||
sign.update();
|
||||
} else {
|
||||
// Remove the sign from the cell since it isn't
|
||||
// a valid sign
|
||||
event.getOriginalCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.hasTargetCell() && event.getTargetCell().hasSigns()) {
|
||||
HashSet<SimpleLocation> signs = event.getTargetCell().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.getTargetCell().getSigns().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,15 +95,15 @@ public class CellCreationSteps {
|
||||
private void secondStep(CreationPlayer cp, Player player, Block block) {
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
|
||||
cp.addSign(new SimpleLocation(block.getLocation()));
|
||||
|
||||
|
||||
//Set the sign's first text
|
||||
Sign sign = (Sign) block.getState();
|
||||
sign.setLine(0, "");
|
||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "");
|
||||
sign.update();
|
||||
|
||||
sign.setLine(0, "");
|
||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "");
|
||||
sign.update();
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Sign added, if you want to select another go ahead otherwise right click on any non-sign block.");
|
||||
}else {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (chest) ----------");
|
||||
|
Loading…
Reference in New Issue
Block a user