Package me.vudu.Conflict.Blocks

Source Code of me.vudu.Conflict.Blocks.BaseBlock

package me.vudu.Conflict.Blocks;


import me.vudu.Conflict.ConflictPlugin;
import me.vudu.Conflict.util.BlockLocation;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.block.SpoutBlock;
import org.getspout.spoutapi.block.design.Texture;
import org.getspout.spoutapi.material.block.GenericCubeCustomBlock;
import org.getspout.spoutapi.player.SpoutPlayer;

/**
* Klasse f�r den Basisblock, auf dem Artefakte gebaut werden k�nnen
* @author vwendel
*
*/
public class BaseBlock  extends GenericCubeCustomBlock{

  /**
   * Farbe (rot/blau)
   */
  private String color;
  /**
   * das Plugin
   */
  private ConflictPlugin plugin;
 
  /**
   * Standart-Konstruktor
   * @param plugin zugeh�riges Plugin
   * @param baseColor Farbedes Blocks (rot/blau)
   */
  public BaseBlock(ConflictPlugin plugin, String baseColor) {
     
        super(plugin, "BaseBlock"+baseColor, ConflictPlugin.BASEBLOCKID, "", 16);
        this.plugin=plugin;
        this.getBlockDesign().setTexture(plugin, new Texture(plugin, "http://tossat.de/~mcbukkit/images/base"+baseColor+"16x16.png", 16, 16, 16));
        this.setHardness(60000);
        this.color=baseColor;
       
    }
 
 
  
   /**
    * speichert die Location dazu global
    */
   public void onBlockPlace(World world, int x, int y, int z, LivingEntity living) {
    
     //nur falls H�he korrekt
     if(y>=ConflictPlugin.minBBHeight && y <= ConflictPlugin.maxBBHeight){
      
       //rot
       if(this.color.equals("red")){
        
           //die 4 benachbarten Bl�cke setzen
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x-1,y,z), ConflictPlugin.baseBlockRed);
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x+1,y,z), ConflictPlugin.baseBlockRed);
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x,y,z-1), ConflictPlugin.baseBlockRed);
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x,y,z+1), ConflictPlugin.baseBlockRed);
            
             //alle 5 BlockPositionen global speichern
             ConflictPlugin.baseBlocksRed.add(new BlockLocation(world.getName(),x, y, z));
             ConflictPlugin.baseBlocksRed.add(new BlockLocation(world.getName(),x-1, y, z));
             ConflictPlugin.baseBlocksRed.add(new BlockLocation(world.getName(),x+1, y, z));
             ConflictPlugin.baseBlocksRed.add(new BlockLocation(world.getName(),x, y, z-1));
             ConflictPlugin.baseBlocksRed.add(new BlockLocation(world.getName(),x, y, z+1));
            
             //red Base Platzieren
             ConflictPlugin.redBase = new BlockLocation(world.toString(),x,y,z);
             this.plugin.setBaseLocationLabelRed();
           
          
              Bukkit.getServer().broadcastMessage("Team RED established their base at "+Integer.toString(x)+"|"+Integer.toString(y)+"|"+Integer.toString(z));
             for(SpoutPlayer p : ConflictPlugin.players){
          p.sendNotification("Basis errichtet", "RED base at "+Integer.toString(x)+"|"+Integer.toString(y)+"|"+Integer.toString(z), Material.SPONGE, (short)0, 10000)
        }
          
              //Blau
       } else{
       
           SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x-1,y,z), ConflictPlugin.baseBlockBlue);
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x+1,y,z), ConflictPlugin.baseBlockBlue);
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x,y,z-1), ConflictPlugin.baseBlockBlue);
             SpoutManager.getMaterialManager().overrideBlock(world.getBlockAt(x,y,z+1), ConflictPlugin.baseBlockBlue);
             ConflictPlugin.baseBlocksBlue.add(new BlockLocation(world.getName(),x, y, z));
             ConflictPlugin.baseBlocksBlue.add(new BlockLocation(world.getName(),x-1, y, z));
             ConflictPlugin.baseBlocksBlue.add(new BlockLocation(world.getName(),x+1, y, z));
             ConflictPlugin.baseBlocksBlue.add(new BlockLocation(world.getName(),x, y, z-1));
             ConflictPlugin.baseBlocksBlue.add(new BlockLocation(world.getName(),x, y, z+1));
           
             ConflictPlugin.blueBase = new BlockLocation(world.getName(),x,y,z);
             this.plugin.setBaseLocationLabelBlue();
           Bukkit.getServer().broadcastMessage("Team BLUE established their base at "+Integer.toString(x)+"|"+Integer.toString(y)+"|"+Integer.toString(z));
           for(SpoutPlayer p : ConflictPlugin.players){
            p.sendNotification("Basis errichtet", "BLUE base at "+Integer.toString(x)+"|"+Integer.toString(y)+"|"+Integer.toString(z), Material.SPONGE, (short)0, 10000)
          }
         }
     }
      
   }
  
   /**
    * zerst�rt alle umliegenden BaseBlocks
    */
   public void onBlockDestroyed(World world, int x, int y, int z) {
    
     if(world.getBlockAt(x-1, y, z) instanceof SpoutBlock){
       world.getBlockAt(x-1, y, z).breakNaturally();
     }
     if(world.getBlockAt(x+1, y, z) instanceof SpoutBlock){
       world.getBlockAt(x+1, y, z).breakNaturally();
     }
     if(world.getBlockAt(x, y, z-1) instanceof SpoutBlock){
       world.getBlockAt(x, y, z-1).breakNaturally();
     }
     if(world.getBlockAt(x, y, z+1) instanceof SpoutBlock){
       world.getBlockAt(x, y, z+1).breakNaturally();
     }
    
    if(this.color=="blue"){
      plugin.resetBaseLocationLabelBlue();
      ConflictPlugin.blueBase=null;
    }else{
      plugin.resetBaseLocationLabelRed();
      ConflictPlugin.redBase=null;
    }
    
   }
  
   /**
    * true, damit man normale Blocks nicht darauf bauen kann
    */
   public boolean onBlockInteract(World world, int x, int y, int z, SpoutPlayer player) {
       return true;
   }
  
 
  
  
   public boolean isProvidingPowerTo(World world, int x, int y, int z, BlockFace face) {
       return false;
   }
  
  
   public boolean isIndirectlyProvidingPowerTo(World world, int x, int y, int z, BlockFace face) {
     return false;
   }
}
TOP

Related Classes of me.vudu.Conflict.Blocks.BaseBlock

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.