Support plugins that use SignChangeEvent to check sign editing permissions (#951)

This commit is contained in:
Nick L 2020-09-14 18:48:34 -05:00 committed by GitHub
parent 581e8881e9
commit 2048a9f31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,16 +118,26 @@ public class BlockEventHandler implements Listener
}
}
//when a player places a sign...
//when a player changes the text of a sign...
@EventHandler(ignoreCancelled = true)
public void onSignChanged(SignChangeEvent event)
{
Player player = event.getPlayer();
Block sign = event.getBlock();
if (player == null || sign == null) return;
String noBuildReason = GriefPrevention.instance.allowBuild(player, sign.getLocation(), sign.getType());
if (noBuildReason != null)
{
GriefPrevention.sendMessage(player, TextMode.Err, noBuildReason);
event.setCancelled(true);
return;
}
//send sign content to online administrators
if (!GriefPrevention.instance.config_signNotifications) return;
Player player = event.getPlayer();
if (player == null) return;
StringBuilder lines = new StringBuilder(" placed a sign @ " + GriefPrevention.getfriendlyLocationString(event.getBlock().getLocation()));
boolean notEmpty = false;
for (int i = 0; i < event.getLines().length; i++)