Support plugins that use SignChangeEvent to check sign editing permissions (#951)
This commit is contained in:
parent
581e8881e9
commit
2048a9f31d
|
|
@ -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)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onSignChanged(SignChangeEvent event)
|
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
|
//send sign content to online administrators
|
||||||
if (!GriefPrevention.instance.config_signNotifications) return;
|
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()));
|
StringBuilder lines = new StringBuilder(" placed a sign @ " + GriefPrevention.getfriendlyLocationString(event.getBlock().getLocation()));
|
||||||
boolean notEmpty = false;
|
boolean notEmpty = false;
|
||||||
for (int i = 0; i < event.getLines().length; i++)
|
for (int i = 0; i < event.getLines().length; i++)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user