Setting a Lever in the Powered Position.

Discussion in 'Plugin Development' started by maxben34, Nov 4, 2013.

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

    maxben34

    Chinwe
    In the code below, I'm attempting to set a placed lever into the powered position.
    I'm getting a class cast exception on the line that looks like
    Code:
     Lever l = (Lever) s1.getBlock().getState();
    Code:java
    1. public void voteEnd(){
    2. World w = Bukkit.getWorld("world");
    3. double sx1 = -1.5;
    4. double sy1 = 67;
    5. double sz1 = 9;
    6. double sx2 = 0.5;
    7. double sx3 = 2.5;
    8.  
    9. final Location s1 = new Location(w,sx1,sy1,sz1);
    10. final Location s2 = new Location(w,sx2,sy1,sz1);
    11. final Location s3 = new Location(w,sx3,sy1,sz1);
    12. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    13. public void run(){
    14. if(song1.size() > song2.size() && song1.size() > song3.size() && song1.size() > song4.size()){
    15. Bukkit.getServer().broadcastMessage(ChatColor.GREEN + ""+ ChatColor.BOLD + "Sail by Awolnation has won the vote with " + song1.size() + "votes!");
    16. Bukkit.getServer().broadcastMessage(ChatColor.BLUE + "Playing Sail!");
    17. if(s1.getBlock().getType() == Material.LEVER){
    18. Lever l = (Lever) s1.getBlock().getState();
    19. l.setPowered(true);
    20. song1End();
     
  2. Offline

    RealDope

    Code:JAVA
    1.  
    2. Level l = (Lever) s1.getBlock().getState().getData();
    3.  
     
  3. Offline

    Chinwe

Thread Status:
Not open for further replies.

Share This Page