A lot of changes

This commit is contained in:
Sam 2018-07-13 02:00:24 +01:00 committed by Alexander Meech
parent 4efb4c1493
commit d86d5172c0
23 changed files with 560 additions and 323 deletions

View File

@ -1,11 +1,5 @@
package mineplex.core.friend.ui; package mineplex.core.friend.ui;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.friend.FriendManager;
import mineplex.core.itemstack.ItemBuilder;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.ChatMessage; import net.minecraft.server.v1_8_R3.ChatMessage;
@ -27,6 +21,12 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.friend.FriendManager;
import mineplex.core.itemstack.ItemBuilder;
public class AddFriendPage implements Listener public class AddFriendPage implements Listener
{ {
private class AnvilContainer extends ContainerAnvil private class AnvilContainer extends ContainerAnvil
@ -120,9 +120,10 @@ public class AddFriendPage implements Listener
_searching = true; _searching = true;
final String name = _itemName; final String name = _itemName;
CommandCenter.Instance.GetClientManager().checkPlayerName(_player, _itemName, new Callback<String>() CommandCenter.Instance.GetClientManager().checkPlayerName(_player, _itemName, result ->
{ {
public void run(String result) // This needs to be run sync otherwise some really dodgy stuff happens.
_friends.runSync(() ->
{ {
_searching = false; _searching = false;
@ -143,7 +144,7 @@ public class AddFriendPage implements Listener
.build()); .build());
_player.playSound(_player.getLocation(), Sound.ITEM_BREAK, 1, .6f); _player.playSound(_player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
} }
} });
}); });
} }
else else

View File

@ -3698,8 +3698,8 @@ public enum GameKit
{ {
"A skilled bowman!", "A skilled bowman!",
C.blankLine, C.blankLine,
receiveArrow(1, 3, 3), receiveArrow(1, 3, 2),
C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Barrage" "Your arrows are " + C.cGreen + "Explosive" + C.cGray + "."
}, },
new KitEntityData<> new KitEntityData<>
( (
@ -3728,11 +3728,13 @@ public enum GameKit
C.blankLine, C.blankLine,
"Take " + C.cGreen + "85%" + C.cGray + " knockback", "Take " + C.cGreen + "85%" + C.cGray + " knockback",
"Deal " + C.cGreen + "115%" + C.cGray + " knockback", "Deal " + C.cGreen + "115%" + C.cGray + " knockback",
C.cYellow + "Drop Weapon" + C.cGray + " to " + C.cGreen + "Spawn a Pet Dog",
"Your dog increases the speed of nearby sheep."
}, },
new KitEntityData<> new KitEntityData<>
( (
Zombie.class, Zombie.class,
new ItemStack(Material.LEATHER), new ItemStack(Material.STONE_SWORD),
new ItemStack[] new ItemStack[]
{ {
new ItemStack(Material.IRON_BOOTS), new ItemStack(Material.IRON_BOOTS),
@ -3751,15 +3753,16 @@ public enum GameKit
null, null,
new String[] new String[]
{ {
"Easily leaps and jumps around.", "Easily leaps and jumps around,",
"Because he delivers letters?", "because he delivers letters?",
C.blankLine, C.blankLine,
leap() click(false, "to use " + C.cGreen + "Seismic Slam"),
}, },
new KitEntityData<> new KitEntityData<>
( (
Zombie.class, Zombie.class,
new ItemStack(Material.RABBIT_HIDE), new ItemStack(Material.IRON_AXE),
new ItemStack[] new ItemStack[]
{ {
new ItemStack(Material.GOLD_BOOTS), new ItemStack(Material.GOLD_BOOTS),

View File

@ -1659,7 +1659,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public void onVote(VoteStartEvent event) public void onVote(VoteStartEvent event)
{ {
getTitles().forceEnable(); getTitles().forceEnable();
getCosmeticManager().setActive(true); getCosmeticManager().showInterface(true);
getCosmeticManager().setHideParticles(false); getCosmeticManager().setHideParticles(false);
} }

View File

@ -841,6 +841,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
continue; continue;
} }
kit.registerEvents();
UtilServer.RegisterEvents(kit); UtilServer.RegisterEvents(kit);
if (kit instanceof LinearUpgradeKit) if (kit instanceof LinearUpgradeKit)
@ -874,6 +875,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
continue; continue;
} }
kit.unregisterEvents();
HandlerList.unregisterAll(kit); HandlerList.unregisterAll(kit);
if (kit instanceof LinearUpgradeKit) if (kit instanceof LinearUpgradeKit)

View File

@ -10,7 +10,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.EnderDragon; import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -29,6 +28,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -166,7 +166,23 @@ public class Dragons extends SoloGame
return; return;
} }
_dragons.forEach(MineplexDragon::updateTarget); List<Player> alive = GetPlayers(true);
_dragons.forEach(dragon ->
{
dragon.updateTarget();
for (Player player : UtilEnt.getPlayersInsideEntity(dragon.getEntity(), alive))
{
if (!Recharge.Instance.use(player, "Hit By " + dragon.getEntity().getEntityId(), 2000, false, false))
{
continue;
}
player.playEffect(EntityEffect.HURT);
UtilAction.velocity(player, UtilAlg.getTrajectory(dragon.getEntity(), player), 1, false, 0, 0.6, 2, true);
}
});
for (Item item : _sparkler.GetItems()) for (Item item : _sparkler.GetItems())
{ {
@ -195,7 +211,7 @@ public class Dragons extends SoloGame
@EventHandler @EventHandler
public void dragonArrowDamage(CustomDamageEvent event) public void dragonArrowDamage(CustomDamageEvent event)
{ {
if (event.GetProjectile() == null) if (event.IsCancelled())
{ {
return; return;
} }
@ -203,34 +219,17 @@ public class Dragons extends SoloGame
for (MineplexDragon dragon : _dragons) for (MineplexDragon dragon : _dragons)
{ {
if (dragon.getEntity().equals(event.GetDamageeEntity())) if (dragon.getEntity().equals(event.GetDamageeEntity()))
{
if (event.GetProjectile() == null)
{ {
dragon.targetSky(); dragon.targetSky();
return;
}
}
}
@EventHandler
public void knockback(CustomDamageEvent event)
{
if (event.IsCancelled())
{
return;
}
Entity damager = event.GetDamagerEntity(true);
Player damagee = event.GetDamageePlayer();
if (damagee == null || damager == null)
{
return;
} }
event.SetCancelled("Dragon"); event.SetCancelled("Dragon");
event.SetKnockback(false); dragon.getEntity().playEffect(EntityEffect.HURT);
return;
damagee.playEffect(EntityEffect.HURT); }
UtilAction.velocity(damagee, UtilAlg.getTrajectory(damager, damagee), 1, false, 0, 0.6, 2, true); }
} }
@EventHandler @EventHandler

View File

@ -300,13 +300,13 @@ public class MilkCow extends SoloGame
event.setCancelled(true); event.setCancelled(true);
player.setItemInHand(new ItemStack(Material.MILK_BUCKET)); player.setItemInHand(new ItemStack(Material.MILK_BUCKET));
player.updateInventory(); Bukkit.broadcastMessage(event.getEventName());
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void bucketFill(PlayerBucketFillEvent event) public void bucketFill(PlayerBucketFillEvent event)
{ {
if (!InProgress()) if (!InProgress() || event.getBlockClicked() == null || !event.getBlockClicked().isLiquid())
{ {
return; return;
} }

View File

@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilItem.ItemCategory;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -41,11 +42,27 @@ public class PerkSeismicSlam extends Perk
private int _radius; private int _radius;
private float _knockbackMagnitude; private float _knockbackMagnitude;
private Map<LivingEntity, Long> _live = new HashMap<>(); private final ItemCategory _itemCategory;
private final Map<LivingEntity, Long> _live = new HashMap<>();
public PerkSeismicSlam() public PerkSeismicSlam()
{ {
super("Seismic Slam", new String[]{C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam"}); this("Seismic Slam", 0, 0, 0, 0, 0, ItemCategory.SHOVEL);
}
public PerkSeismicSlam(String name, long cooldown, long time, int damage, int radius, float knockbackMagnitude, ItemCategory itemCategory)
{
super(name, new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Seismic Slam"
});
_cooldown = cooldown;
_time = time;
_damage = damage;
_radius = radius;
_knockbackMagnitude = knockbackMagnitude;
_itemCategory = itemCategory;
} }
@Override @Override
@ -59,54 +76,20 @@ public class PerkSeismicSlam extends Perk
} }
@EventHandler @EventHandler
public void deactivateDeath(PlayerDeathEvent event) public void leap(PlayerInteractEvent event)
{ {
Player player = event.getEntity(); if (!UtilEvent.isAction(event, ActionType.R) || UtilBlock.usable(event.getClickedBlock()))
if (!hasPerk(player))
{
return;
}
if (_live.containsKey(player))
{
_live.remove(player);
}
}
@EventHandler
public void Leap(PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
if (!UtilEvent.isAction(event, ActionType.R))
{
return;
}
if (UtilBlock.usable(event.getClickedBlock()))
{ {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UtilItem.isSpade(player.getItemInHand())) if (!UtilItem.is(player.getItemInHand(), _itemCategory) || !hasPerk(player) || !Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{ {
return; return;
} }
if (!hasPerk(player))
{
return;
}
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
return;
// Action // Action
Vector vec = player.getLocation().getDirection(); Vector vec = player.getLocation().getDirection();
if (vec.getY() < 0) if (vec.getY() < 0)
@ -124,7 +107,7 @@ public class PerkSeismicSlam extends Perk
} }
@EventHandler @EventHandler
public void Slam(UpdateEvent event) public void slam(UpdateEvent event)
{ {
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
{ {
@ -151,9 +134,15 @@ public class PerkSeismicSlam extends Perk
continue; continue;
} }
if (UtilPlayer.isSpectator(cur)) // Inform
if (cur instanceof Player)
{ {
continue; if (!Manager.canHurt(player, (Player) cur))
{
return;
}
UtilPlayer.message(cur, F.main(Manager.getName(), F.name(player.getName()) + " hit you with " + F.skill(GetName()) + "."));
} }
// Damage Event // Damage Event
@ -161,12 +150,6 @@ public class PerkSeismicSlam extends Perk
// Condition // Condition
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
// Inform
if (cur instanceof Player)
{
UtilPlayer.message(cur, F.main("Game", F.name(player.getName()) + " hit you with " + F.skill(GetName()) + "."));
}
} }
// Effect // Effect
@ -185,7 +168,7 @@ public class PerkSeismicSlam extends Perk
} }
@EventHandler @EventHandler
public void Knockback(CustomDamageEvent event) public void knockback(CustomDamageEvent event)
{ {
if (event.GetReason() == null || !event.GetReason().contains(GetName())) if (event.GetReason() == null || !event.GetReason().contains(GetName()))
{ {
@ -194,4 +177,10 @@ public class PerkSeismicSlam extends Perk
event.AddKnockback(GetName(), _knockbackMagnitude); event.AddKnockback(GetName(), _knockbackMagnitude);
} }
@EventHandler
public void deactivateDeath(PlayerDeathEvent event)
{
_live.remove(event.getEntity());
}
} }

View File

@ -285,7 +285,7 @@ public class SquidShooters extends SoloGame
if (damagee != null) if (damagee != null)
{ {
damagee.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 8, 0, false, false), true); damagee.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10, 0, false, false), true);
} }
} }

View File

@ -16,7 +16,9 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilParticle;
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.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.effects.LineParticle; import mineplex.core.common.util.particles.effects.LineParticle;
@ -78,14 +80,14 @@ public class KitRetroSquid extends Kit
while (!lineParticle.update()) while (!lineParticle.update())
{ {
Location from = lineParticle.getLastLocation().subtract(0, 1, 0); Location from = lineParticle.getLastLocation().subtract(0, 1, 0);
Player closet = UtilPlayer.getClosest(from, 2, player); Player closest = UtilPlayer.getClosest(from, 2, player);
if (closet == null) if (closest == null)
{ {
continue; continue;
} }
from = closet.getLocation(); from = closest.getLocation();
UtilPlayer.getInRadius(from, 2).forEach((hit, scale) -> UtilPlayer.getInRadius(from, 2).forEach((hit, scale) ->
{ {
@ -94,7 +96,8 @@ public class KitRetroSquid extends Kit
return; return;
} }
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1);
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, closest.getLocation().add(0, 1, 0), null, 0.1F, 10, ViewDist.LONG);
Manager.GetDamage().NewDamageEvent(hit, player, null, DamageCause.CUSTOM, 7 * scale, true, true, true, player.getName(), NAME); Manager.GetDamage().NewDamageEvent(hit, player, null, DamageCause.CUSTOM, 7 * scale, true, true, true, player.getName(), NAME);
}); });

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.tug; package nautilus.game.arcade.game.games.tug;
import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -14,10 +15,11 @@ public class TugItem
private final ItemStack _itemStack; private final ItemStack _itemStack;
private final int _cost; private final int _cost;
TugItem(EntityType entityType, ItemStack itemStack, int cost) TugItem(EntityType entityType, int cost)
{ {
_entityType = entityType; _entityType = entityType;
_itemStack = new ItemBuilder(itemStack) _itemStack = new ItemBuilder(Material.MONSTER_EGG)
.setData(UtilEnt.getEntityEggData(entityType))
.setTitle(C.cYellow + "Spawn a " + UtilEnt.getName(entityType) + C.mBody + " - " + C.cGold + cost + " Gold") .setTitle(C.cYellow + "Spawn a " + UtilEnt.getName(entityType) + C.mBody + " - " + C.cGold + cost + " Gold")
.build(); .build();
_cost = cost; _cost = cost;

View File

@ -1,7 +1,10 @@
package nautilus.game.arcade.game.games.tug; package nautilus.game.arcade.game.games.tug;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -16,18 +19,25 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.mineplex.anticheat.checks.move.Glide;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -41,8 +51,10 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.tug.entities.TugChicken;
import nautilus.game.arcade.game.games.tug.entities.TugCow; import nautilus.game.arcade.game.games.tug.entities.TugCow;
import nautilus.game.arcade.game.games.tug.entities.TugEntity; import nautilus.game.arcade.game.games.tug.entities.TugEntity;
import nautilus.game.arcade.game.games.tug.entities.TugPig;
import nautilus.game.arcade.game.games.tug.entities.TugSheep; import nautilus.game.arcade.game.games.tug.entities.TugSheep;
import nautilus.game.arcade.game.games.tug.kits.KitTugArcher; import nautilus.game.arcade.game.games.tug.kits.KitTugArcher;
import nautilus.game.arcade.game.games.tug.kits.KitTugLeaper; import nautilus.game.arcade.game.games.tug.kits.KitTugLeaper;
@ -65,10 +77,10 @@ public class TugOfWool extends TeamGame
private static final int GOLD_SLOT = 8; private static final int GOLD_SLOT = 8;
private final Set<TugTeam> _teams; private final Set<TugTeam> _teams;
private final Set<TugItem> _items; private final List<TugItem> _items;
private final Map<Player, Double> _gold;
private float _speed = 1; private float _speed = 1;
private int _animalsPerIteration = 1;
private long _lastIncrease; private long _lastIncrease;
public TugOfWool(ArcadeManager manager) public TugOfWool(ArcadeManager manager)
@ -81,13 +93,17 @@ public class TugOfWool extends TeamGame
}, DESCRIPTION); }, DESCRIPTION);
_teams = new HashSet<>(); _teams = new HashSet<>();
_items = new HashSet<>(); _items = new ArrayList<>();
_gold = new HashMap<>();
DamageFall = false; DamageFall = false;
DeathOut = false; DeathOut = false;
DeathSpectateSecs = 10; DeathSpectateSecs = 10;
HungerSet = 20; HungerSet = 20;
AntiHack antiHack = Managers.get(AntiHack.class);
antiHack.addIgnoredCheck(Glide.class);
registerChatStats( registerChatStats(
Kills, Kills,
Deaths, Deaths,
@ -109,12 +125,9 @@ public class TugOfWool extends TeamGame
_teams.add(red); _teams.add(red);
_teams.add(blue); _teams.add(blue);
_items.add(new TugItem( _items.add(new TugItem(EntityType.CHICKEN, 3));
EntityType.COW, _items.add(new TugItem(EntityType.PIG, 5));
new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.COW)) _items.add(new TugItem(EntityType.COW, 10));
.build(),
3
));
} }
private List<Location> setupCrops(String key) private List<Location> setupCrops(String key)
@ -169,7 +182,7 @@ public class TugOfWool extends TeamGame
_teams.forEach(team -> _teams.forEach(team ->
{ {
for (int i = 0; i < _animalsPerIteration && team.getEntities().size() < MAX_ANIMALS; i++) if (team.getEntities().size() < MAX_ANIMALS)
{ {
team.getEntities().add(spawnTugEntity(EntityType.SHEEP, team)); team.getEntities().add(spawnTugEntity(EntityType.SHEEP, team));
} }
@ -179,9 +192,8 @@ public class TugOfWool extends TeamGame
if (UtilTime.elapsed(_lastIncrease, INCREASE_TIME)) if (UtilTime.elapsed(_lastIncrease, INCREASE_TIME))
{ {
Announce(F.main(getArcadeManager().getName(), "Your animals grow hungrier. Their " + F.elem("Speed") + " and " + F.name("Numbers") + " have increased!")); Announce(F.main(getArcadeManager().getName(), "Your animals grow hungrier. Their " + F.elem("Speed") + " have increased!"));
_speed *= 1.1; _speed *= 1.1;
_animalsPerIteration++;
DeathSpectateSecs++; DeathSpectateSecs++;
_lastIncrease = System.currentTimeMillis(); _lastIncrease = System.currentTimeMillis();
} }
@ -216,6 +228,10 @@ public class TugOfWool extends TeamGame
return new TugSheep(this, team, getSpawn(team)); return new TugSheep(this, team, getSpawn(team));
case COW: case COW:
return new TugCow(this, team, getSpawn(team)); return new TugCow(this, team, getSpawn(team));
case PIG:
return new TugPig(this, team, getSpawn(team));
case CHICKEN:
return new TugChicken(this, team, getSpawn(team));
default: default:
return null; return null;
} }
@ -242,13 +258,8 @@ public class TugOfWool extends TeamGame
List<Location> targetCrops = team.getEnemy().getCrops(); List<Location> targetCrops = team.getEnemy().getCrops();
List<TugEntity> targetEntities = team.getEnemy().getEntities(); List<TugEntity> targetEntities = team.getEnemy().getEntities();
team.getEntities().removeIf(tugEntity -> team.getEntities().forEach(tugEntity ->
{ {
if (!tugEntity.getEntity().isValid())
{
return true;
}
tugEntity.updateName(); tugEntity.updateName();
LivingEntity targetEntity = tugEntity.getTargetEntity(); LivingEntity targetEntity = tugEntity.getTargetEntity();
@ -267,7 +278,7 @@ public class TugOfWool extends TeamGame
tugEntity.move(); tugEntity.move();
} }
return false; return;
} }
Location targetLocation = tugEntity.getTargetLocation(); Location targetLocation = tugEntity.getTargetLocation();
@ -277,7 +288,7 @@ public class TugOfWool extends TeamGame
// Attempt to target entity. If successful no need to handle anything else // Attempt to target entity. If successful no need to handle anything else
if (tugEntity.attemptTarget(otherTugEntity.getEntity())) if (tugEntity.attemptTarget(otherTugEntity.getEntity()))
{ {
return false; return;
} }
} }
@ -288,27 +299,40 @@ public class TugOfWool extends TeamGame
if (closest == null) if (closest == null)
{ {
return false; return;
} }
tugEntity.setTargetLocation(closest); tugEntity.setTargetLocation(closest);
} }
else if (tugEntity.attemptEat()) else if (tugEntity.attemptEat())
{ {
for (Player player : team.getEnemy().getGameTeam().GetPlayers(true))
{
incrementGold(player, 3);
}
targetCrops.remove(targetLocation); targetCrops.remove(targetLocation);
return true; return;
} }
// Finally move the entity closer to it's target // Finally move the entity closer to it's target
tugEntity.move(); tugEntity.move();
return false;
}); });
}); });
_teams.forEach(team -> team.getEntities().removeIf(tugEntity -> !tugEntity.getEntity().isValid()));
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void damage(CustomDamageEvent event) public void damage(CustomDamageEvent event)
{ {
if (!IsLive())
{
return;
}
event.SetDamageToLevel(false);
if (event.IsCancelled()) if (event.IsCancelled())
{ {
return; return;
@ -335,7 +359,15 @@ public class TugOfWool extends TeamGame
} }
else else
{ {
setGold(damager, getGold(damager) + (damagee instanceof Player ? 2 : 1)); if (damagee instanceof Player)
{
incrementGold(damager, 0.3);
}
else
{
event.SetKnockback(false);
incrementGold(damager, 0.2);
}
} }
} }
@ -393,7 +425,6 @@ public class TugOfWool extends TeamGame
} }
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
@ -408,13 +439,13 @@ public class TugOfWool extends TeamGame
player.getInventory().setItem(slot++, item.getItemStack()); player.getInventory().setItem(slot++, item.getItemStack());
} }
setGold(player, 0); setGold(player, _gold.getOrDefault(player, 0D) / 2D);
} }
@EventHandler @EventHandler
public void itemInteract(PlayerInteractEvent event) public void itemInteract(PlayerInteractEvent event)
{ {
if (!IsLive()) if (!IsLive() || event.getAction() == Action.PHYSICAL)
{ {
return; return;
} }
@ -437,7 +468,7 @@ public class TugOfWool extends TeamGame
if (gold < item.getCost()) if (gold < item.getCost())
{ {
player.sendMessage(F.main(Manager.getName(), "You don't " + C.cGold + "Gold" + C.Reset + " to buy a " + F.name(UtilEnt.getName(item.getEntityType())) + ". You need " + F.count(item.getCost() - gold) + " more.")); player.sendMessage(F.main(Manager.getName(), "You don't have enough " + C.cGold + "Gold" + C.mBody + " to buy a " + F.name(UtilEnt.getName(item.getEntityType())) + ". You need " + F.count(item.getCost() - gold) + " more."));
return; return;
} }
else if (!Recharge.Instance.use(player, "Buy Animal", PURCHASE_COOLDOWN, true, true)) else if (!Recharge.Instance.use(player, "Buy Animal", PURCHASE_COOLDOWN, true, true))
@ -445,13 +476,38 @@ public class TugOfWool extends TeamGame
return; return;
} }
setGold(player, gold - item.getCost()); incrementGold(player, -item.getCost());
spawnFor(item.getEntityType(), player); spawnFor(item.getEntityType(), player);
return; return;
} }
} }
} }
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_gold.remove(event.getPlayer());
}
@EventHandler
public void updatePassiveGold(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !IsLive())
{
return;
}
for (Player player : GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
incrementGold(player, 0.05);
}
}
@Override @Override
@EventHandler @EventHandler
public void ScoreboardUpdate(UpdateEvent event) public void ScoreboardUpdate(UpdateEvent event)
@ -542,25 +598,41 @@ public class TugOfWool extends TeamGame
return _speed; return _speed;
} }
public void setGold(Player player, int amount) public void incrementGold(Player player, double amount)
{ {
if (amount == 0) setGold(player, _gold.getOrDefault(player, 0D) + amount);
}
public void setGold(Player player, double amount)
{
if (amount >= 50)
{
amount = 50;
}
int amountFloor = (int) Math.floor(amount);
player.setLevel(amountFloor);
player.setExp((float) (amount % 1));
if (amountFloor == 0)
{ {
player.getInventory().setItem(GOLD_SLOT, null); player.getInventory().setItem(GOLD_SLOT, null);
} }
else else
{ {
player.getInventory().setItem(GOLD_SLOT, new ItemBuilder(Material.GOLD_NUGGET, Math.max(1, amount)) player.getInventory().setItem(GOLD_SLOT, new ItemBuilder(Material.GOLD_NUGGET, Math.max(1, amountFloor))
.setTitle(C.cGold + amount + " Gold") .setTitle(C.cGold + amountFloor + " Gold")
.addLore("Collect gold by killing animals", "and players! You can then spend", "it on more animals!") .addLore("Collect gold by killing animals", "and players! You can then spend", "it on more animals!")
.build()); .build());
} }
_gold.put(player, amount);
} }
public int getGold(Player player) public int getGold(Player player)
{ {
ItemStack itemStack = player.getInventory().getItem(GOLD_SLOT); return (int) Math.floor(_gold.getOrDefault(player, 0D));
return itemStack == null ? 0 : itemStack.getAmount();
} }
@EventHandler @EventHandler
@ -571,5 +643,10 @@ public class TugOfWool extends TeamGame
String[] args = event.getMessage().split(" "); String[] args = event.getMessage().split(" ");
_speed = Float.parseFloat(args[1]); _speed = Float.parseFloat(args[1]);
} }
else if (event.getMessage().startsWith("/gold"))
{
String[] args = event.getMessage().split(" ");
incrementGold(event.getPlayer(), Integer.parseInt(args[1]));
}
} }
} }

View File

@ -0,0 +1,54 @@
package nautilus.game.arcade.game.games.tug.entities;
import org.bukkit.Location;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import nautilus.game.arcade.game.games.tug.TugOfWool;
import nautilus.game.arcade.game.games.tug.TugTeam;
public class TugChicken extends TugEntity<Chicken>
{
public TugChicken(TugOfWool host, TugTeam team, Location spawn)
{
super(host, team, spawn, 3, 500);
}
@Override
public Chicken spawn(Location location)
{
Chicken chicken = location.getWorld().spawn(location, Chicken.class);
chicken.setCustomNameVisible(true);
chicken.setMaxHealth(20);
chicken.setHealth(chicken.getMaxHealth());
return chicken;
}
@Override
public void attack(LivingEntity other)
{
other.damage(4, _entity);
_entity.setVelocity(new Vector(0, 0.5, 0));
}
@Override
public boolean attemptTarget(LivingEntity other)
{
return false;
}
@Override
public void move()
{
super.move();
if (_entity.getTicksLived() % 10 == 0)
{
attackNearby();
}
}
}

View File

@ -4,12 +4,10 @@ import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Cow; import org.bukkit.entity.Cow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.tug.TugOfWool; import nautilus.game.arcade.game.games.tug.TugOfWool;
import nautilus.game.arcade.game.games.tug.TugTeam; import nautilus.game.arcade.game.games.tug.TugTeam;
@ -19,7 +17,7 @@ public class TugCow extends TugEntity<Cow>
public TugCow(TugOfWool host, TugTeam team, Location spawn) public TugCow(TugOfWool host, TugTeam team, Location spawn)
{ {
super(host, team, spawn, 3, 500); super(host, team, spawn, 4, 400);
} }
@Override @Override
@ -28,7 +26,7 @@ public class TugCow extends TugEntity<Cow>
Cow cow = location.getWorld().spawn(location, Cow.class); Cow cow = location.getWorld().spawn(location, Cow.class);
cow.setCustomNameVisible(true); cow.setCustomNameVisible(true);
cow.setMaxHealth(40); cow.setMaxHealth(60);
cow.setHealth(cow.getMaxHealth()); cow.setHealth(cow.getMaxHealth());
return cow; return cow;
@ -37,7 +35,8 @@ public class TugCow extends TugEntity<Cow>
@Override @Override
public void attack(LivingEntity other) public void attack(LivingEntity other)
{ {
other.damage(20, _entity);
other.getWorld().playSound(other.getLocation(), Sound.COW_IDLE, 1, (float) Math.random());
} }
@Override @Override
@ -46,34 +45,22 @@ public class TugCow extends TugEntity<Cow>
return false; return false;
} }
@Override
public float getSpeed()
{
return super.getSpeed() * 1.5F;
}
@Override @Override
public void move() public void move()
{ {
super.move(); super.move();
if (_entity.getTicksLived() % 10 == 0) UtilParticle.PlayParticleToAll(ParticleType.CRIT, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0, 1, ViewDist.LONG);
{
Location location = _entity.getLocation();
UtilEnt.getInRadius(location, 4).forEach((entity, scale) -> if (_entity.getTicksLived() % 5 == 0)
{ {
if (entity.equals(_entity) || entity instanceof Player) attackNearby();
{
return;
}
Vector velocity = UtilAlg.getTrajectory(location, entity.getLocation())
.setY(0.6);
UtilAction.velocity(entity, velocity);
location.getWorld().playSound(location, Sound.COW_IDLE, 1, (float) Math.random());
});
} }
} }
@Override
public float getSpeed()
{
return super.getSpeed() * 2;
}
} }

View File

@ -7,6 +7,7 @@ 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.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -30,7 +31,7 @@ public abstract class TugEntity<T extends LivingEntity>
protected final TugOfWool _host; protected final TugOfWool _host;
protected final TugTeam _team; protected final TugTeam _team;
protected final T _entity; protected final T _entity;
private final int _attackRangeSquared, _attackRate; private final int _attackRange, _attackRate;
private Location _targetLocation; private Location _targetLocation;
private LivingEntity _targetEntity; private LivingEntity _targetEntity;
@ -41,7 +42,7 @@ public abstract class TugEntity<T extends LivingEntity>
_host = host; _host = host;
_team = team; _team = team;
_entity = spawn(spawn); _entity = spawn(spawn);
_attackRangeSquared = attackRange * attackRange; _attackRange = attackRange;
_attackRate = attackRate; _attackRate = attackRate;
UtilEnt.vegetate(_entity); UtilEnt.vegetate(_entity);
@ -54,7 +55,7 @@ public abstract class TugEntity<T extends LivingEntity>
public boolean attemptAttack(LivingEntity other) public boolean attemptAttack(LivingEntity other)
{ {
if (!UtilTime.elapsed(_lastAttack, _attackRate) || UtilMath.offsetSquared(_entity, other) > _attackRangeSquared) if (!UtilTime.elapsed(_lastAttack, _attackRate) || UtilMath.offsetSquared(_entity, other) > _attackRange * _attackRange)
{ {
return false; return false;
} }
@ -139,6 +140,19 @@ public abstract class TugEntity<T extends LivingEntity>
UtilEnt.CreatureMoveFast(_entity, location.clone().add(direction), getSpeed()); UtilEnt.CreatureMoveFast(_entity, location.clone().add(direction), getSpeed());
} }
public void attackNearby()
{
UtilEnt.getInRadius(_entity.getLocation(), _attackRange).forEach((entity, scale) ->
{
if (entity.equals(_entity) || entity instanceof Player || _team.isEntity(entity))
{
return;
}
attack(entity);
});
}
public float getSpeed() public float getSpeed()
{ {
return _host.getSpeed(); return _host.getSpeed();

View File

@ -0,0 +1,70 @@
package nautilus.game.arcade.game.games.tug.entities;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.tug.TugOfWool;
import nautilus.game.arcade.game.games.tug.TugTeam;
public class TugPig extends TugEntity<Pig>
{
public TugPig(TugOfWool host, TugTeam team, Location spawn)
{
super(host, team, spawn, 3, 500);
}
@Override
public Pig spawn(Location location)
{
Pig pig = location.getWorld().spawn(location, Pig.class);
pig.setCustomNameVisible(true);
pig.setMaxHealth(20);
pig.setHealth(pig.getMaxHealth());
return pig;
}
@Override
public void attack(LivingEntity other)
{
other.damage(8, _entity);
int ticks = 20;
Item item = UtilItem.dropItem(new ItemStack(Material.PORK), _entity.getLocation().add(0, 1, 0), false, false, ticks, false);
item.setVelocity(new Vector((Math.random() - 0.5) / 2, 0.3, (Math.random() - 0.5) / 2));
_host.getArcadeManager().runSyncLater(() ->
{
Location location = item.getLocation();
UtilEnt.getInRadius(location, 3).forEach((entity, scale) ->
{
if (entity.equals(_entity) || entity instanceof Player && _team.getGameTeam().HasPlayer((Player) entity))
{
return;
}
_host.getArcadeManager().GetDamage().NewDamageEvent(entity, other, null, DamageCause.CUSTOM, 6 * scale, true, true, true, entity.getName(), "Explosive Pork");
});
item.getWorld().playSound(location, Sound.EXPLODE, 1, 1);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, location, null, 0, 2, ViewDist.NORMAL);
}, ticks);
}
}

View File

@ -20,12 +20,14 @@ public class TugSheep extends TugEntity<Sheep>
{ {
Sheep sheep = location.getWorld().spawn(location, Sheep.class); Sheep sheep = location.getWorld().spawn(location, Sheep.class);
sheep.setColor(_team.getGameTeam().getDyeColor()); sheep.setColor(_team.getGameTeam().getDyeColor());
sheep.setMaxHealth(10);
sheep.setHealth(sheep.getMaxHealth());
return sheep; return sheep;
} }
@Override @Override
public void attack(LivingEntity other) public void attack(LivingEntity other)
{ {
other.damage(4 + Math.random(), _entity); other.damage(4, _entity);
} }
} }

View File

@ -1,14 +1,24 @@
package nautilus.game.arcade.game.games.tug.kits; package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.game.kit.GameKit; import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher; import nautilus.game.arcade.kit.perks.PerkFletcher;
@ -44,8 +54,7 @@ public class KitTugArcher extends Kit
private static final Perk[] PERKS = private static final Perk[] PERKS =
{ {
new PerkFletcher(3, 3, true), new PerkFletcher(3, 2, true),
new PerkBarrage(8, 150, true, false, true)
}; };
public KitTugArcher(ArcadeManager manager) public KitTugArcher(ArcadeManager manager)
@ -59,4 +68,31 @@ public class KitTugArcher extends Kit
player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(PLAYER_ARMOUR); player.getInventory().setArmorContents(PLAYER_ARMOUR);
} }
@EventHandler
public void projectileHit(ProjectileHitEvent event)
{
ProjectileSource shooter = event.getEntity().getShooter();
if (!(shooter instanceof Player))
{
return;
}
Player player = (Player) shooter;
if (!HasKit(player))
{
return;
}
Location location = event.getEntity().getLocation().add(0, 1, 0);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, null, 0, 1, ViewDist.LONG);
location.getWorld().playSound(location, Sound.EXPLODE, 1.3F, 1);
UtilEnt.getInRadius(event.getEntity().getLocation(), 6).forEach((nearby, scale) ->
{
Manager.GetDamage().NewDamageEvent(nearby, player, event.getEntity(), DamageCause.CUSTOM, 8 * scale, true, true, false, player.getName(), "Explosive Arrow");
});
}
} }

View File

@ -4,14 +4,14 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilItem.ItemCategory;
import mineplex.core.game.kit.GameKit; import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.smash.perks.golem.PerkSeismicSlam;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkLeap;
import nautilus.game.arcade.kit.perks.PerkMammoth;
public class KitTugLeaper extends Kit public class KitTugLeaper extends Kit
{ {
@ -41,7 +41,7 @@ public class KitTugLeaper extends Kit
private static final Perk[] PERKS = private static final Perk[] PERKS =
{ {
new PerkLeap("Leap", 1.1, 0.9, 3000) new PerkSeismicSlam("Seismic Slam", 5000, 250, 10, 6, 1, ItemCategory.AXE),
}; };
public KitTugLeaper(ArcadeManager manager) public KitTugLeaper(ArcadeManager manager)

View File

@ -1,17 +1,36 @@
package nautilus.game.arcade.game.games.tug.kits; package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Material; import java.util.HashMap;
import org.bukkit.entity.Player; import java.util.Map;
import org.bukkit.inventory.ItemStack; import java.util.concurrent.TimeUnit;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.SpigotUtil;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilItem;
import mineplex.core.game.kit.GameKit; import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import nautilus.game.arcade.kit.perks.PerkMammoth; import nautilus.game.arcade.kit.perks.PerkMammoth;
public class KitTugSmasher extends Kit public class KitTugSmasher extends Kit
@ -19,7 +38,7 @@ public class KitTugSmasher extends Kit
private static final ItemStack[] PLAYER_ITEMS = private static final ItemStack[] PLAYER_ITEMS =
{ {
new ItemBuilder(Material.IRON_SWORD) new ItemBuilder(Material.STONE_SWORD)
.setUnbreakable(true) .setUnbreakable(true)
.build() .build()
}; };
@ -45,6 +64,11 @@ public class KitTugSmasher extends Kit
new PerkMammoth() new PerkMammoth()
}; };
private static final String WOLF_NAME = "Spawn Dog";
private static final long WOLF_COOLDOWN = TimeUnit.SECONDS.toMillis(20);
private final Map<LivingEntity, Player> _petOwners = new HashMap<>();
public KitTugSmasher(ArcadeManager manager) public KitTugSmasher(ArcadeManager manager)
{ {
super(manager, GameKit.TUG_SMASHER, PERKS); super(manager, GameKit.TUG_SMASHER, PERKS);
@ -56,4 +80,89 @@ public class KitTugSmasher extends Kit
player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(PLAYER_ARMOUR); player.getInventory().setArmorContents(PLAYER_ARMOUR);
} }
@EventHandler
public void playerDropItem(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
if (!HasKit(player) || !UtilItem.isSword(event.getItemDrop().getItemStack()) || _petOwners.containsValue(player) || !Recharge.Instance.usable(player, WOLF_NAME, true))
{
return;
}
Manager.GetGame().CreatureAllowOverride = true;
GameTeam team = Manager.GetGame().GetTeam(player);
Wolf wolf = player.getWorld().spawn(player.getLocation(), Wolf.class);
wolf.setCollarColor(team.getDyeColor());
wolf.setCustomName(team.GetColor() + player.getName() + "'s Dog");
wolf.setCustomNameVisible(true);
wolf.setMaxHealth(25);
wolf.setHealth(25);
UtilEnt.vegetate(wolf);
SpigotUtil.setOldOwner_RemoveMeWhenSpigotFixesThis(wolf, player);
wolf.setOwner(player);
player.sendMessage(F.main(Manager.getName(), "You spawned your " + F.name("Pet Dog") + "."));
_petOwners.put(wolf, player);
Manager.GetGame().CreatureAllowOverride = false;
}
@EventHandler
public void updatePets(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
{
return;
}
_petOwners.forEach((wolf, player) ->
{
for (LivingEntity entity : UtilEnt.getInRadius(wolf.getLocation(), 6).keySet())
{
if (entity instanceof Sheep)
{
entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20, 1, false, false));
}
}
UtilEnt.CreatureMove(wolf, player.getLocation(), 1);
});
}
@EventHandler
public void entityDeath(EntityDeathEvent event)
{
Player player = _petOwners.remove(event.getEntity());
if (player != null)
{
Recharge.Instance.useForce(player, WOLF_NAME, WOLF_COOLDOWN, true);
}
}
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
_petOwners.entrySet().removeIf(entry ->
{
if (event.getEntity().equals(entry.getValue()))
{
entry.getKey().remove();
return true;
}
return false;
});
}
@Override
public void unregisterEvents()
{
_petOwners.clear();
}
} }

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -113,7 +112,7 @@ public class GameTeamModule extends Module
{ {
List<Player> partyMembers = new ArrayList<>(party.getMembers()); List<Player> partyMembers = new ArrayList<>(party.getMembers());
// Remove party members that are already on a team // Remove party members that are already on a team
partyMembers.removeIf(other -> game.GetTeam(other) != null); partyMembers.removeIf(other -> game.GetTeam(other) != null || !players.contains(other));
// Keep going until we just have 1 party member left // Keep going until we just have 1 party member left
while (partyMembers.size() > 1) while (partyMembers.size() > 1)
@ -153,7 +152,7 @@ public class GameTeamModule extends Module
List<Player> friends = friendManager.Get(player).getFriends().stream() List<Player> friends = friendManager.Get(player).getFriends().stream()
.filter(friendStatus -> friendStatus.Online) .filter(friendStatus -> friendStatus.Online)
.map(friendStatus -> UtilPlayer.searchExact(friendStatus.UUID)) .map(friendStatus -> UtilPlayer.searchExact(friendStatus.UUID))
.filter(Objects::nonNull) .filter(players::contains)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!friends.isEmpty()) if (!friends.isEmpty())

View File

@ -50,11 +50,6 @@ public abstract class Kit implements Listener
return _gameKit.getDisplayName(); return _gameKit.getDisplayName();
} }
public ItemStack GetItemInHand()
{
return _gameKit.getEntityData().getInHand();
}
public KitAvailability GetAvailability() public KitAvailability GetAvailability()
{ {
return _gameKit.getAvailability(); return _gameKit.getAvailability();
@ -120,4 +115,12 @@ public abstract class Kit implements Listener
public void Selected(Player player) { } public void Selected(Player player) { }
public void registerEvents()
{
}
public void unregisterEvents()
{
}
} }

View File

@ -1,112 +0,0 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import org.bukkit.Effect;
import org.bukkit.EntityEffect;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
public class PerkSeismicSlamCS extends Perk
{
public PerkSeismicSlamCS()
{
super("Ground Pound", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Ground Pound"
});
}
@EventHandler
public void Leap(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 10000, true, true))
return;
//Action
double range = 6;
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), range);
for (LivingEntity cur : targets.keySet())
{
if (!(cur instanceof Player))
return;
if (cur.equals(player))
continue;
Player other = (Player)cur;
if (!Manager.GetGame().IsAlive(other))
continue;
if (Manager.GetGame().GetTeam(other).equals(Manager.GetGame().GetTeam(player)))
continue;
//Damage Event
Manager.GetDamage().NewDamageEvent(cur, player, null,
DamageCause.CUSTOM, 8 * targets.get(cur) + 1, false, true, false,
player.getName(), GetName());
//Velocity
UtilAction.velocity(cur,
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
1.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.6, true);
//Condition
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
//Inform
if (cur instanceof Player)
UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
}
//Effect
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 2f, 0.2f);
for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4d).keySet())
if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur))
cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getTypeId());
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}
}

View File

@ -29,7 +29,6 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.managers.voting.command.MapRatingsCommand; import nautilus.game.arcade.managers.voting.command.MapRatingsCommand;
import nautilus.game.arcade.managers.voting.event.VoteStartEvent; import nautilus.game.arcade.managers.voting.event.VoteStartEvent;
import nautilus.game.arcade.managers.voting.types.MapVote;
import nautilus.game.arcade.managers.voting.ui.VotingPage; import nautilus.game.arcade.managers.voting.ui.VotingPage;
import nautilus.game.arcade.managers.voting.ui.VotingShop; import nautilus.game.arcade.managers.voting.ui.VotingShop;