Skip to content

Commit

Permalink
Do a initial update on the sign after we placed it.
Browse files Browse the repository at this point in the history
  • Loading branch information
zh32 committed Jul 5, 2014
1 parent 5f1ab11 commit cab1abd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/main/java/de/zh32/teleportsigns/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ protected PlayerListener(TeleportSigns plugin) {
@EventHandler
public void onSignChange(SignChangeEvent e) {
if (e.getLine(0).equalsIgnoreCase("[tsigns]") && e.getPlayer().hasPermission("teleportsigns.create")) {
ServerInfo info = data.getServer(e.getLine(1));
String layout = e.getLine(2).equals("") ? "default" : e.getLine(2);
if (data.getLayout(layout) != null) {
final ServerInfo info = data.getServer(e.getLine(1));
String layoutName = e.getLine(2).equals("") ? "default" : e.getLine(2);
final SignLayout layout = data.getLayout(layoutName);
if (layout != null) {
if (info != null) {
TeleportSign ts = new TeleportSign(e.getLine(1), e.getBlock().getLocation(), layout);
data.addSign(ts);
final TeleportSign ts = new TeleportSign(e.getLine(1), e.getBlock().getLocation(), layoutName);
data.addSign(ts);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {

@Override
public void run() {
plugin.getUpdateUtil().updateSign(ts, layout, info);
}
}, 1L);
e.getPlayer().sendMessage(ChatColor.GREEN + "Sign created.");
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/zh32/teleportsigns/UpdateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void run() {
}
}

private void updateSign(TeleportSign sign, SignLayout layout, ServerInfo server) {
void updateSign(TeleportSign sign, SignLayout layout, ServerInfo server) {
Location location = sign.getLocation();
if (location.getWorld().getChunkAt(location).isLoaded()) {
Block b = location.getBlock();
Expand Down

0 comments on commit cab1abd

Please sign in to comment.