Fixed some bugs with the Editor kit

This commit is contained in:
Morten 2015-07-20 20:40:43 +02:00
parent c5f7c4fe0e
commit b239f0af28

View File

@ -72,6 +72,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class WitherGame extends TeamGame implements IBlockRestorer public class WitherGame extends TeamGame implements IBlockRestorer
@ -327,7 +328,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
//On Player interact with a placed block by Editor //On Player interact with a placed block by Editor
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) public void onPlayerInteract(final PlayerInteractEvent event)
{ {
if(!IsLive()) if(!IsLive())
{ {
@ -337,18 +338,30 @@ public class WitherGame extends TeamGame implements IBlockRestorer
{ {
return; return;
} }
if(GetTeam(event.getPlayer()).GetColor() == ChatColor.RED)
{
return;
}
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
{ {
Block clickedBlock = event.getClickedBlock(); Block clickedBlock = event.getClickedBlock();
if(_locationsOfBlocks.contains(clickedBlock.getLocation())) if(_locationsOfBlocks.contains(clickedBlock.getLocation()))
{ {
if(!(event.getPlayer().getInventory().getItem(event.getPlayer().getInventory().getHeldItemSlot()) instanceof Block)) new BukkitRunnable()
{ {
UtilParticle.PlayParticle(ParticleType.FLAME, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers());
event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); @Override
Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000); public void run()
} {
if(!(event.getPlayer().getItemInHand().getType().isBlock()) || event.getPlayer().getItemInHand().getType() == Material.AIR)
{
UtilParticle.PlayParticle(ParticleType.FLAME, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers());
event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f);
Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000);
}
}
}.runTaskLater(Manager.getPlugin(), 5);
} }
} }
} }