Spleef Update

Map parser block stuff
This commit is contained in:
Chiss 2014-08-15 15:28:50 +10:00
parent 697897b967
commit 29db90837d
7 changed files with 134 additions and 83 deletions

View File

@ -26,6 +26,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -635,6 +639,30 @@ public class MapParser extends JavaPlugin implements Listener
event.setCancelled(true);
}
@EventHandler
public void DisableBurn(BlockBurnEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void DisableFire(BlockSpreadEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void DisableFade(BlockFadeEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void DisableDecay(LeavesDecayEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void Updates(PlayerMoveEvent event)
{

View File

@ -373,8 +373,6 @@ public abstract class Game implements Listener
//Set Spawn Data
team.SetSpawnRequirement(this.SpawnDistanceRequirement);
System.out.println("Created Team: " + team.GetName());
}
@ -393,8 +391,6 @@ public abstract class Game implements Listener
return false;
}
public void RestrictKits()
{
//Null Default
@ -409,7 +405,6 @@ public abstract class Game implements Listener
for (Perk perk : kit.GetPerks())
UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.GetPlugin());
}
}
public void DeregisterKits()

View File

@ -37,7 +37,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.mineware.order.Order;
import nautilus.game.arcade.game.games.mineware.random.*;
import nautilus.game.arcade.game.games.spleef.kits.KitLeaper;
import nautilus.game.arcade.game.games.runner.kits.KitLeaper;
import nautilus.game.arcade.kit.Kit;
public class MineWare extends SoloGame

View File

@ -4,10 +4,13 @@ import java.lang.reflect.Field;
import java.util.HashMap;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
@ -17,7 +20,11 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
@ -36,7 +43,7 @@ public class Spleef extends SoloGame
new Kit[]
{
new KitLeaper(manager),
new KitSnowballer(manager),
new KitBrawler(manager),
new KitArcher(manager)
},
@ -47,22 +54,67 @@ public class Spleef extends SoloGame
"1 Hunger per block smashed!",
"Last player alive wins!"
});
this.DamagePvP = false;
this.WorldWaterDamage = 4;
this.PrepareFreeze = false;
}
@EventHandler
public void SnowballDamage(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Snowball))
return;
Snowball ball = (Snowball)event.getEntity();
if (ball.getShooter() == null || !(ball.getShooter() instanceof Player))
return;
Location loc = ball.getLocation().add(ball.getVelocity().multiply(0.8));
Block block = loc.getBlock();
//Find Nearest if hit nothing :O
if (block.getType() == Material.AIR)
{
Block closest = null;
double closestDist = 0;
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.AIR)
continue;
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist)
{
closest = other;
closestDist = dist;
}
}
if (closest != null)
block = closest;
}
BlockFade(block, (Player)ball.getShooter(), false);
}
@EventHandler
public void ArrowDamage(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Arrow))
return;
final Arrow arrow = (Arrow)event.getEntity();
final double velocity = arrow.getVelocity().length();
if (!(arrow.getShooter() instanceof Player))
return;
final Player player = (Player)arrow.getShooter();
Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
@ -88,14 +140,14 @@ public class Spleef extends SoloGame
Block block = arrow.getWorld().getBlockAt(x, y, z);
double radius = 0.5 + velocity/1.6d;
BlockFade(block, player);
BlockFade(block, player, false);
for (Block other : UtilBlock.getInRadius(block.getLocation().add(0.5, 0.5, 0.5), radius).keySet())
{
BlockFade(other, player);
BlockFade(other, player, true);
}
arrow.remove();
}
catch (Exception e)
@ -105,39 +157,55 @@ public class Spleef extends SoloGame
}
}, 0);
}
@EventHandler(priority = EventPriority.LOW)
public void BlockDamage(BlockDamageEvent event)
{
if (!this.IsLive())
return;
if (!this.IsAlive(event.getPlayer()))
return;
event.setCancelled(true);
BlockFade(event.getBlock(), event.getPlayer());
BlockFade(event.getBlock(), event.getPlayer(), false);
//Snowball
if (GetKit(event.getPlayer()) instanceof KitSnowballer)
if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte)0, 16))
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL));
}
@EventHandler
//Ignore
//@EventHandler
public void LeapDamage(PerkLeapEvent event)
{
if (!UtilEnt.isGrounded(event.GetPlayer()))
return;
for (Block block : UtilBlock.getInRadius(event.GetPlayer().getLocation().subtract(0, 1, 0), 3d, 0).keySet())
{
BlockFade(block, event.GetPlayer());
BlockFade(block, event.GetPlayer(), false);
}
}
public void BlockFade(Block block, Player player)
public void BlockFade(Block block, Player player, boolean slowDamage)
{
AddStat(player, "BlocksBroken", 1, false, false);
UtilPlayer.hunger(player, 1);
//Prevent Super Hunger from Bow
if (Recharge.Instance.use(player, GetName() + " Hunger", 50, false, false))
if (block.getTypeId() != 7)
UtilPlayer.hunger(player, 1);
if (!slowDamage)
{
Break(block);
return;
}
//Wool and Stained Clay
if (block.getTypeId() == 35 || block.getTypeId() == 159)
{
@ -168,7 +236,7 @@ public class Spleef extends SoloGame
else
Break(block);
}
//Grass
else if (block.getTypeId() == 2)
{
@ -183,7 +251,7 @@ public class Spleef extends SoloGame
else if (block.getData() == 0)
block.setData((byte)2);
else
Break(block);
}
@ -194,22 +262,22 @@ public class Spleef extends SoloGame
Break(block);
}
}
public void Break(Block block)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(0);
}
@EventHandler
public void Hunger(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (!IsLive())
return;
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() <= 0)
@ -217,10 +285,10 @@ public class Spleef extends SoloGame
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.STARVATION, 1, false, true, false,
"Starvation", GetName());
UtilPlayer.message(player, F.main("Game", "Break blocks to restore hunger!"));
}
UtilPlayer.hunger(player, -1);
}
}

View File

@ -35,7 +35,7 @@ public class SpleefTeams extends TeamGame
new Kit[]
{
new KitLeaper(manager),
new KitSnowballer(manager),
new KitBrawler(manager),
new KitArcher(manager)
},

View File

@ -20,22 +20,23 @@ public class KitBrawler extends Kit
new String[]
{
"Much stronger knockback than other kits."
"Very leap. Such knockback. Wow."
},
new Perk[]
{
new PerkLeap("Leap", 1.2, 1.2, 6000),
new PerkSmasher(),
new PerkKnockback(0.6)
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
EntityType.SKELETON,
new ItemStack(Material.IRON_AXE));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
}
}

View File

@ -1,41 +0,0 @@
package nautilus.game.arcade.game.games.spleef.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitLeaper extends Kit
{
public KitLeaper(ArcadeManager manager)
{
super(manager, "Jumper", KitAvailability.Free,
new String[]
{
"Leap to escape and damage blocks!"
},
new Perk[]
{
new PerkLeap("Smashing Leap", 1.2, 1.2, 8000),
new PerkKnockback(0.3)
},
EntityType.PIG_ZOMBIE,
new ItemStack(Material.STONE_AXE));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE));
}
}