Small fixed. Preparing updating.

This commit is contained in:
Morten 2015-10-12 21:26:40 +02:00
parent 040f99f62a
commit 3c85079d6d
2 changed files with 96 additions and 13 deletions

View File

@ -5,23 +5,35 @@ import java.util.HashMap;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.mineware.MineWare;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.material.Wool; import org.bukkit.material.Wool;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.sun.xml.internal.ws.resources.UtilMessages;
public class ChallengeBouncingBlock extends Challenge public class ChallengeBouncingBlock extends Challenge
{ {
@ -30,7 +42,7 @@ public class ChallengeBouncingBlock extends Challenge
public ChallengeBouncingBlock(MineWare host) public ChallengeBouncingBlock(MineWare host)
{ {
super(host, ChallengeType.FirstComplete, "Bouncing Block", "Jump and punch the wool", "Land on red wool = score reset"); super(host, ChallengeType.FirstComplete, "Bouncing Block", "Jump and punch the wool!", "Land on red wool = score reset", "First to 10 wins!");
} }
@Override @Override
@ -56,7 +68,9 @@ public class ChallengeBouncingBlock extends Challenge
woolBlocks.setType(Material.AIR); woolBlocks.setType(Material.AIR);
} }
_scoreBlocks.clear(); _scoreBlocks.clear();
_playerScore.clear();
Host.StrictAntiHack = true; Host.StrictAntiHack = true;
Host.DamageFall = false;
} }
@Override @Override
@ -64,11 +78,12 @@ public class ChallengeBouncingBlock extends Challenge
{ {
for(Player player : Host.GetPlayers(true)) for(Player player : Host.GetPlayers(true))
{ {
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 4)); player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 5));
_playerScore.put(player, 0); _playerScore.put(player, 0);
} }
Host.StrictAntiHack = false; Host.StrictAntiHack = false;
Host.DamageFall = true;
} }
@Override @Override
@ -108,16 +123,69 @@ public class ChallengeBouncingBlock extends Challenge
return; return;
} }
_playerScore.put(event.getPlayer(), _playerScore.get(event.getPlayer())+1); _playerScore.put(event.getPlayer(), _playerScore.get(event.getPlayer()) + 1);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.SUCCESSFUL_HIT, 0.2f, 0.2f); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.SUCCESSFUL_HIT, 0.2f, 0.2f);
event.getClickedBlock().setType(Material.AIR); event.getClickedBlock().setType(Material.AIR);
spawnRandomWool(getArenaSize(9), (UtilMath.r(7)+3)); spawnRandomWool(getArenaSize(9), (UtilMath.r(7) + 3));
if(_playerScore.get(event.getPlayer()) >= 10) if(_playerScore.get(event.getPlayer()) >= 10)
{ {
SetCompleted(event.getPlayer()); SetCompleted(event.getPlayer());
} }
}
@EventHandler
public void onPlayerFallDamage(EntityDamageEvent event)
{
if(!Host.IsLive())
{
return;
}
if(!(event.getEntity() instanceof Player))
{
return;
}
if(event.getCause() != DamageCause.FALL)
{
return;
}
event.setCancelled(true);
Player player = (Player) event.getEntity();
Location pLocation = player.getLocation();
Block blockUnderPlayer = player.getWorld().getBlockAt(pLocation.getBlockX(), pLocation.getBlockY() - 1, pLocation.getBlockZ());
{
if(blockUnderPlayer.getType() == Material.WOOL)
{
Wool wool = (Wool) blockUnderPlayer;
if(wool.getColor() == DyeColor.RED)
{
_playerScore.put(player, 0);
UtilPlayer.message(player, "You landed on a RED wool! Score Reset!");
}
}
}
}
@EventHandler
public void scoreHandler(UpdateEvent event)
{
if(!Host.IsLive())
{
return;
}
if(event.getType() != UpdateType.FASTEST)
{
return;
}
for(Player player : Host.GetPlayers(true))
{
if(isDone(player))
{
continue;
}
UtilTextBottom.display(ChatColor.YELLOW + "Your Score: " + ChatColor.GREEN + _playerScore.get(player), player);
}
} }
private void spawnStartingWool() private void spawnStartingWool()
@ -136,6 +204,12 @@ public class ChallengeBouncingBlock extends Challenge
{ {
if(UtilMath.r(200) == 50) if(UtilMath.r(200) == 50)
{ {
Byte color = (byte) UtilMath.r(16);
while(color == 14)
{
color = (byte) UtilMath.r(16);
}
b.setType(Material.WOOL); b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16)); b.setData((byte) UtilMath.r(16));
_scoreBlocks.add(b); _scoreBlocks.add(b);
@ -154,13 +228,19 @@ public class ChallengeBouncingBlock extends Challenge
private void spawnRandomWool(int size, int height) private void spawnRandomWool(int size, int height)
{ {
int x = UtilMath.r(size*2) - size; int x = UtilMath.r(size * 2) - size;
int y = height; int y = height;
int z = UtilMath.r(size*2) - size; int z = UtilMath.r(size * 2) - size;
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
Byte color = (byte) UtilMath.r(16);
while(color == 14)
{
color = (byte) UtilMath.r(16);
}
b.setType(Material.WOOL); b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16)); b.setData(color);
UtilFirework.playFirework(b.getLocation(), Type.BALL, ((Wool) b).getColor().getColor(), false, false); UtilFirework.playFirework(b.getLocation(), Type.BALL, ((Wool) b).getColor().getColor(), false, false);
_scoreBlocks.add(b); _scoreBlocks.add(b);

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
@ -41,7 +42,7 @@ public class ChallengeDogvsCat extends Challenge
public ChallengeDogvsCat(MineWare host) public ChallengeDogvsCat(MineWare host)
{ {
super(host, ChallengeType.FirstComplete, "Dogs VS Cats", "If you are a dog, bark!", "If you are a cat, meow!", "Left-Click to Bark/Meow!"); super(host, ChallengeType.FirstComplete, "Dogs VS Cats", "Look up and Bark/Meow!", "Keep an eye on your Action bar!");
} }
@Override @Override
@ -100,6 +101,7 @@ public class ChallengeDogvsCat extends Challenge
player.getInventory().addItem( player.getInventory().addItem(
ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, ChatColor.GREEN + "Left-click to bark!")); ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, ChatColor.GREEN + "Left-click to bark!"));
UtilPlayer.message(player, "You are a DOG! Bark!");
} }
else else
{ {
@ -110,6 +112,7 @@ public class ChallengeDogvsCat extends Challenge
player.getInventory().addItem( player.getInventory().addItem(
ItemStackFactory.Instance.CreateStack(Material.SUGAR, (byte) 0, 1, ChatColor.GREEN + "Left-click to meow!")); ItemStackFactory.Instance.CreateStack(Material.SUGAR, (byte) 0, 1, ChatColor.GREEN + "Left-click to meow!"));
UtilPlayer.message(player, "You are a CAT! Meow!");
} }
looped++; looped++;
} }