Advertisement
McMatt_sc

Untitled

May 28th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package me.mcmatt.shops;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.block.Sign;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.block.Action;
  8. import org.bukkit.event.block.SignChangeEvent;
  9. import org.bukkit.event.player.PlayerInteractEvent;
  10.  
  11. public class Signs implements Listener {
  12.  
  13. @EventHandler
  14. public void onSignChange(SignChangeEvent e) {
  15. if (e.getLine(0).equalsIgnoreCase("[shop]")){
  16. String name = e.getPlayer().getCustomName();
  17. e.setLine(0, "ยง9" + name + "'s");
  18. e.setLine(1, "Shop");
  19. }
  20. }
  21.  
  22. @EventHandler
  23. public void onPlayerInteract(PlayerInteractEvent e) {
  24. if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
  25. if (e.getClickedBlock().getState() instanceof Sign) {
  26. Sign s = (Sign) e.getClickedBlock().getState();
  27. if (s.getLine(0).equals("ยง9[Shop]")) {
  28. e.getPlayer().sendMessage(ChatColor.RED + "You clicked the shop sign");
  29. }
  30.  
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement