[unSolved]Sign Manipulation

Discussion in 'Plugin Development' started by ilethz, Jul 13, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    ilethz

    Hello everybody!
    just somebody can tell me the Code for Sign Manipulation, Like i right click on the sign and he teleports me to Spawn or send a Message


    *~@ilethz the noob!
     
  2. Offline

    chasechocolate

    No. What's the point of us giving you code? We will be happy to help you if you have any questions, but won't be spoon feeding you code. Search it up! I think thebcbroz made a video tutorial similar to this.
     
    xTrollxDudex and Levi2241 like this.
  3. Offline

    ilethz

    hm ok.. i watched the video, but it's something wrong, i put the sign and i right click teleport me to spawn but i cant destroy blocks! look
    at my code
    Code:java
    1. package ilethz.spawnSign;
    2.  
    3. import java.util.HashMap;
    4.  
    5. import org.bukkit.Location;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.block.SignChangeEvent;
    10. import org.bukkit.event.player.PlayerInteractEvent;
    11. import org.bukkit.plugin.PluginManager;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class mainClass extends JavaPlugin implements Listener {
    15. public final HashMap <Location, String > signs = new HashMap<Location, String>();
    16.  
    17. @Override
    18. public void onEnable(){
    19. PluginManager pm = getServer().getPluginManager();
    20.  
    21. pm.registerEvents(this, this);
    22. }
    23.  
    24. @EventHandler(ignoreCancelled = true)
    25. public void onSignCreate(SignChangeEvent sign){
    26. Player player = sign.getPlayer();
    27. if(sign.getLine(0).equalsIgnoreCase("Spawn")){
    28. player.sendMessage("§bSign created!");
    29. }
    30. }
    31. @EventHandler
    32. public void onSignChange(SignChangeEvent event){
    33. if(event.getLine(0).equalsIgnoreCase("Spawn")){
    34. signs.put(event.getBlock().getLocation(), event.getPlayer().getName());
    35. }
    36. }
    37.  
    38. [B]@EventHandler[/B]
    39. [FONT=mceinline]public void onBlockBreak(BlockBreakEvent event){[/FONT]
    40. [FONT=mceinline]Player player = event.getPlayer();[/FONT]
    41. [FONT=mceinline]if(signs.containsKey(event.getBlock().getLocation()) && !signs.containsValue(event.getPlayer().getName()) [/FONT]
    42. [FONT=mceinline]|| !player.isOp());[/FONT]
    43. [FONT=mceinline]event.setCancelled(true);[/FONT]
    44. [FONT=mceinline]}[/FONT]
    45.  
    46.  
    47. @EventHandler
    48. public void onPlayerInteract(PlayerInteractEvent event){
    49. Player player = event.getPlayer();
    50. if(signs.containsKey(event.getClickedBlock().getLocation())){
    51. player.teleport(player.getWorld().getSpawnLocation());
    52. }
    53. }
    54. {
    55. }
    56. }
     
  4. Offline

    xTrollxDudex

    ilethz
    Breaking blocks has nothing to do with this code
     
  5. Offline

    ilethz



    I just watched TheBCBroz Video D:
     
  6. Offline

    xTrollxDudex

    ilethz
    Soz! The dark background of syntax makes it difficult to see on an iPod :(

    I think you can remove the line with signs.containValue(event.getPlayer().getName()) because the location is enough for checking blocks. Also, it might help to add an else if(!signs.contains(event.getBlock().getLocation())){} just to make sure
     
  7. Offline

    ilethz

    why i i left click and server give a big error!
    [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page