jonassvensson4

Join

Sep 2nd, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1.     @EventHandler
  2.     public void onSignChange(SignChangeEvent event) // Skapar skylten
  3.     {
  4.        
  5.     ConfigurationSection sectionA = this.getConfig().getConfigurationSection( "root.lobbies" );
  6.     ConfigurationSection sectionB = this.getConfig().getConfigurationSection( "root.arenor" );
  7.    
  8.     String rad1 = event.getLine(1);
  9.    
  10.     Player player = event.getPlayer();
  11.     String[] lines = event.getLines();
  12.    
  13.         if( player.hasPermission("event.sign.join") )  
  14.         {
  15.             if(( event.getLine(0).contains("[join]")
  16.                ||event.getLine(0).contains("[Join]")))
  17.             {
  18.                 if(( sectionA.contains( rad1 )
  19.                    ||sectionB.contains( rad1 )))
  20.                 {
  21.                     if( !lines[1].isEmpty() )
  22.                     {
  23.                         event.setLine(0, "§a[Join]");
  24.                         event.setLine(2, "" + playerCount + "/" + maxPlayers );
  25.                         player.sendMessage(ChatColor.GREEN + "Join sign created!");
  26.                     }
  27.                     else
  28.                     {
  29.                         player.sendMessage(ChatColor.RED + "Please set a valid lobby name on line 2");
  30.                         event.setCancelled(true);
  31.                     }
  32.                 }
  33.                 else
  34.                 {
  35.                     player.sendMessage(ChatColor.RED + "Please set a valid lobby name on line 2");
  36.                 }
  37.             }
  38.         }
  39.    }
  40.     @EventHandler
  41.     public void onPlayerInteract(PlayerInteractEvent event) // Klickar på skylten
  42.     {
  43.         Player player = event.getPlayer();
  44.         Block block = event.getClickedBlock();
  45.         Action action = event.getAction();
  46.            
  47.             if(action == Action.RIGHT_CLICK_BLOCK)
  48.             {
  49.                 if(((block.getType() == Material.SIGN)
  50.                 || (block.getType() == Material.SIGN_POST)
  51.                 || (block.getType() == Material.WALL_SIGN)))
  52.                 {
  53.                     Sign sign = (Sign) block.getState();
  54.                    
  55.                     if( sign.getLine( 0 ).contains( "[Join]" ) )
  56.                     {
  57.                         String name = sign.getLine( 1 );
  58.                         TeleportToLobby( player, name );
  59.                         playerCount++;
  60.                     }
  61.                 }          
  62.             }
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment