Update Fishing Day challenge.
This commit is contained in:
parent
19b79398da
commit
49b8aa74a6
@ -147,11 +147,11 @@ public class MineWare extends SoloGame implements IThrown
|
||||
public void PopulateOrders()
|
||||
{
|
||||
_challenges.add(ChallengeFishingDay.class);
|
||||
_challenges.add(ChallengeTreasureDigger.class);
|
||||
_challenges.add(ChallengeFastFood.class);
|
||||
_challenges.add(ChallengeBuildRace.class);
|
||||
_challenges.add(ChallengeAnvilDance.class);
|
||||
_challenges.add(ChallengeFallingBlocks.class);
|
||||
// _challenges.add(ChallengeTreasureDigger.class);
|
||||
// _challenges.add(ChallengeFastFood.class);
|
||||
// _challenges.add(ChallengeBuildRace.class);
|
||||
// _challenges.add(ChallengeAnvilDance.class);
|
||||
// _challenges.add(ChallengeFallingBlocks.class);
|
||||
|
||||
// _challenges.add(ChallengeWaveCrush.class);
|
||||
// _challenges.add(ChallengePickASide.class);
|
||||
|
@ -2,25 +2,38 @@ package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ChallengeFishingDay extends Challenge
|
||||
{
|
||||
private int _spacing = 4;
|
||||
|
||||
private int _fishingRodSlot = 0;
|
||||
|
||||
private int _startingLureLevel = 3;
|
||||
|
||||
private ArrayList<Location> _spawns = new ArrayList<Location>();
|
||||
|
||||
public ChallengeFishingDay(MineWare host)
|
||||
@ -41,30 +54,15 @@ public class ChallengeFishingDay extends Challenge
|
||||
{
|
||||
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
|
||||
{
|
||||
for(int y = 0; y < 8; y++)
|
||||
for(int y = 0; y < 6; y++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, y, z);
|
||||
|
||||
if(y == 0)
|
||||
{
|
||||
b.setType(Material.BEDROCK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
|
||||
{
|
||||
if(y == 7)
|
||||
{
|
||||
_spawns.add(getCenter().clone().add(x + 0.5, 7.1, z + 0.5));
|
||||
}
|
||||
b.setType(Material.STONE);
|
||||
}
|
||||
else if(y <= 6)
|
||||
{
|
||||
b.setType(Material.WATER);
|
||||
}
|
||||
}
|
||||
|
||||
if(y == 1)
|
||||
else if(y == 1)
|
||||
{
|
||||
int random = UtilMath.r(100);
|
||||
|
||||
@ -81,23 +79,40 @@ public class ChallengeFishingDay extends Challenge
|
||||
b.setType(Material.CLAY);
|
||||
}
|
||||
}
|
||||
//
|
||||
// if(y == 5)
|
||||
// {
|
||||
// if(_spawns.size() < Host.GetPlayers(true).size())
|
||||
// {
|
||||
// if(x % _spacing == 0 && z % _spacing == 0)
|
||||
// {
|
||||
// for(Location platform : UtilShapes.getCircle(new Location(getCenter().getWorld(), x, 6.1, z), false, _spacing))
|
||||
// {
|
||||
// platform.getBlock().setType(Material.SANDSTONE);
|
||||
// addBlock(platform.getBlock());
|
||||
// }
|
||||
//
|
||||
// _spawns.add(getCenter().clone().add(x + 0.5, 6.1, z + 0.5));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
else
|
||||
{
|
||||
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
|
||||
{
|
||||
if(y == 5)
|
||||
{
|
||||
_spawns.add(getCenter().clone().add(x + 0.5, 6.1, z + 0.5));
|
||||
}
|
||||
|
||||
b.setType(Material.STONE);
|
||||
}
|
||||
else if(y < 6 && y > 1)
|
||||
{
|
||||
b.setType(Material.WATER);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// if(y == 5)
|
||||
// {
|
||||
// if(_spawns.size() < Host.GetPlayers(true).size())
|
||||
// {
|
||||
// if(x % _spacing == 0 && z % _spacing == 0)
|
||||
// {
|
||||
// for(Location platform : UtilShapes.getCircle(new Location(getCenter().getWorld(), x, 6.1, z), false, _spacing))
|
||||
// {
|
||||
// platform.getBlock().setType(Material.SANDSTONE);
|
||||
// addBlock(platform.getBlock());
|
||||
// }
|
||||
//
|
||||
// _spawns.add(getCenter().clone().add(x + 0.5, 6.1, z + 0.5));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
addBlock(b);
|
||||
}
|
||||
@ -108,24 +123,29 @@ public class ChallengeFishingDay extends Challenge
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
Host.ItemPickup = true;
|
||||
|
||||
ItemBuilder item = new ItemBuilder(Material.FISHING_ROD);
|
||||
item.addEnchantment(Enchantment.LURE, 1);
|
||||
item.addEnchantment(Enchantment.LURE, _startingLureLevel);
|
||||
item.setUnbreakable(true);
|
||||
|
||||
for(Player player : Host.GetPlayers(true))
|
||||
{
|
||||
player.getInventory().setItem(4, item.build());
|
||||
player.getInventory().setHeldItemSlot(4);
|
||||
player.getInventory().setItem(_fishingRodSlot, item.build());
|
||||
player.getInventory().setHeldItemSlot(_fishingRodSlot);
|
||||
}
|
||||
|
||||
improveFishingRodTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
|
||||
Host.ItemPickup = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysics(BlockPhysicsEvent event)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||
{
|
||||
if(!Host.IsLive())
|
||||
{
|
||||
@ -137,6 +157,29 @@ public class ChallengeFishingDay extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerFish(PlayerFishEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(event.getCaught() != null)
|
||||
{
|
||||
UtilTextBottom.display(C.cGreen + C.Bold + "You caught a fish!", player);
|
||||
|
||||
Entity entity = event.getCaught();
|
||||
Item item = (Item) entity;
|
||||
|
||||
ItemStack fish = item.getItemStack();
|
||||
fish.setType(Material.RAW_FISH);
|
||||
fish.getData().setData((byte) UtilMath.r(3));
|
||||
|
||||
player.getInventory().addItem(fish);
|
||||
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
@ -145,4 +188,60 @@ public class ChallengeFishingDay extends Challenge
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void improveFishingRodTask()
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(!Host.IsLive() || !Host.isChallengeStarted())
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
for(Player player : Host.GetPlayers(true))
|
||||
{
|
||||
ArrayList<ItemStack> items = UtilInv.getItems(player);
|
||||
|
||||
for(ItemStack contents : items)
|
||||
{
|
||||
if(contents.getType() == Material.FISHING_ROD)
|
||||
{
|
||||
ItemBuilder item = new ItemBuilder(contents);
|
||||
|
||||
if(item.getEnchantmentLevel(Enchantment.LURE) < 7)
|
||||
{
|
||||
item.addEnchantment(Enchantment.LURE, item.getEnchantmentLevel(Enchantment.LURE) + 1);
|
||||
player.getInventory().setItem(_fishingRodSlot, item.build());
|
||||
informForUpgrade(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(Host.getArcadeManager().getPlugin(), 200, 200);
|
||||
}
|
||||
|
||||
private void informForUpgrade(Player player)
|
||||
{
|
||||
UtilTextBottom.display(C.cWhite + C.Bold + "Your chances of catching a fish have increased.", player);
|
||||
player.playSound(player.getLocation(), Sound.CLICK, 1.0F, 1.5F);
|
||||
}
|
||||
|
||||
private void dropExplosives(Location location)
|
||||
{
|
||||
// TODO: Drop explosives that deal knockback.
|
||||
}
|
||||
|
||||
private void createExplosionWithKnocback(Location location)
|
||||
{
|
||||
// TODO: After explosives are detonated, create the explosion.
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user