Partial QA changes

This commit is contained in:
Sam 2018-07-12 00:27:52 +01:00 committed by Alexander Meech
parent 1687e48bcd
commit 445d620ab2
23 changed files with 1121 additions and 292 deletions

View File

@ -876,13 +876,13 @@ public class UtilEnt
if (!(ent instanceof Creature))
return;
if (UtilMath.offset(ent.getLocation(), target) < 0.1)
if (UtilMath.offsetSquared(ent.getLocation(), target) < 0.1)
return;
EntityCreature ec = ((CraftCreature)ent).getHandle();
NavigationAbstract nav = ec.getNavigation();
if (UtilMath.offset(ent.getLocation(), target) > 16)
if (UtilMath.offsetSquared(ent.getLocation(), target) > 16 * 16)
{
Location newTarget = ent.getLocation();
@ -906,10 +906,10 @@ public class UtilEnt
if (!(ent instanceof Creature))
return false;
if (UtilMath.offset(ent.getLocation(), target) < 0.1)
if (UtilMath.offsetSquared(ent.getLocation(), target) < 0.1)
return false;
if (UtilMath.offset(ent.getLocation(), target) < 2)
if (UtilMath.offsetSquared(ent.getLocation(), target) < 4)
speed = Math.min(speed, 1f);
EntityCreature ec = ((CraftCreature)ent).getHandle();

View File

@ -64,7 +64,7 @@ public class ParticleFiveYear extends ParticleGadget
int color, height = _bufferedImage.getHeight() / 2, width = _bufferedImage.getWidth() / 2;
double yaw = Math.toRadians(location.getYaw());
for (int y = 1; y < _bufferedImage.getHeight(); y++)
for (int y = 2; y < _bufferedImage.getHeight() - 1; y++)
{
for (int x = 0; x < _bufferedImage.getWidth() - 1; x++)
{

View File

@ -29,7 +29,6 @@ import org.bukkit.entity.Spider;
import org.bukkit.entity.Squid;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Witch;
import org.bukkit.entity.Wither;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zombie;
import org.bukkit.inventory.EntityEquipment;
@ -3687,6 +3686,90 @@ public enum GameKit
getAchievementsFor(AchievementCategory.SURVIVAL_GAMES)
),
// Tug of Wool
TUG_ARCHER
(
0,
GameDisplay.Tug,
"Farmer Joe",
null,
new String[]
{
"A skilled bowman!",
C.blankLine,
receiveArrow(1, 3, 3),
C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Barrage"
},
new KitEntityData<>
(
Skeleton.class,
new ItemStack(Material.BOW),
new ItemStack[]
{
new ItemStack(Material.CHAINMAIL_BOOTS),
new ItemStack(Material.CHAINMAIL_LEGGINGS),
new ItemStack(Material.CHAINMAIL_CHESTPLATE),
new ItemStack(Material.CHAINMAIL_HELMET)
}
)
),
TUG_SMASHER
(
1,
GameDisplay.Tug,
"Butch",
null,
new String[]
{
"Giant and muscular, easily smacks others around.",
"Like my dog.",
C.blankLine,
"Take " + C.cGreen + "85%" + C.cGray + " knockback",
"Deal " + C.cGreen + "115%" + C.cGray + " knockback",
},
new KitEntityData<>
(
Zombie.class,
new ItemStack(Material.LEATHER),
new ItemStack[]
{
new ItemStack(Material.IRON_BOOTS),
new ItemStack(Material.IRON_LEGGINGS),
new ItemStack(Material.IRON_CHESTPLATE),
new ItemStack(Material.IRON_HELMET)
}
)
),
TUG_LEAPER
(
2,
GameDisplay.Tug,
"Postman Pat",
null,
new String[]
{
"Easily leaps and jumps around.",
"Because he delivers letters?",
C.blankLine,
leap()
},
new KitEntityData<>
(
Zombie.class,
new ItemStack(Material.RABBIT_HIDE),
new ItemStack[]
{
new ItemStack(Material.GOLD_BOOTS),
new ItemStack(Material.GOLD_LEGGINGS),
new ItemStack(Material.GOLD_CHESTPLATE),
new ItemStack(Material.GOLD_HELMET)
}
)
),
// Turf Wars
TURF_WARS_MARKSMAN

View File

@ -73,6 +73,7 @@ import nautilus.game.arcade.game.games.spleef.Spleef;
import nautilus.game.arcade.game.games.squidshooters.SquidShooters;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewSolo;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewTeams;
import nautilus.game.arcade.game.games.tug.TugOfWool;
import nautilus.game.arcade.game.games.turfforts.TurfForts;
import nautilus.game.arcade.game.games.typewars.TypeWars;
import nautilus.game.arcade.game.games.uhc.UHCSolo;
@ -206,6 +207,7 @@ public enum GameType implements Voteable
CakeWarsDuos(CakeWarsDuos.class, GameDisplay.CakeWarsDuos),
SquidShooters(SquidShooters.class, GameDisplay.SquidShooter),
Tug(TugOfWool.class, GameDisplay.Tug),
Event(EventGame.class, GameDisplay.Event, new GameType[]{
GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build,

View File

@ -26,6 +26,7 @@ public class OverpoweredBridge extends Bridge
new ItemStack(Material.ENCHANTMENT_TABLE),
new ItemStack(Material.BOOKSHELF, 32),
new ItemStack(Material.EXP_BOTTLE, 64),
new ItemStack(Material.EXP_BOTTLE, 64),
new ItemStack(Material.COOKED_BEEF, 64),
new ItemStack(Material.MUSHROOM_SOUP),
new ItemStack(Material.MUSHROOM_SOUP),
@ -40,7 +41,7 @@ public class OverpoweredBridge extends Bridge
new AbsorptionFix()
.register(this);
setBridgeTime(TimeUnit.MINUTES.toMillis(3));
setBridgeTime(TimeUnit.MINUTES.toMillis(5));
}
@EventHandler(priority = EventPriority.MONITOR)

View File

@ -1,152 +0,0 @@
package nautilus.game.arcade.game.games.dragons;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import org.bukkit.Location;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class DragonTeamsData
{
public DragonsTeams Host;
public EnderDragon Dragon;
public Entity TargetEntity = null;
public Location Target = null;
public Location Location = null;
public float Pitch = 0;
public Vector Velocity = new Vector(0,0,0);
public double RangeBest = 1000;
public long RangeTime = 0;
public DragonTeamsData(DragonsTeams host, EnderDragon dragon)
{
Host = host;
Dragon = dragon;
Velocity = dragon.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(dragon.getLocation().getDirection());
Location = dragon.getLocation();
}
public void Move()
{
Turn();
Location.add(Velocity);
Location.add(0, -Pitch, 0);
Location.setPitch(-1 * Pitch);
Location.setYaw(180 + UtilAlg.GetYaw(Velocity));
Dragon.teleport(Location);
}
private void Turn()
{
//Pitch
float desiredPitch = UtilAlg.GetPitch(UtilAlg.getTrajectory(Location, Target));
if (desiredPitch < Pitch) Pitch = (float)(Pitch - 0.05);
if (desiredPitch > Pitch) Pitch = (float)(Pitch + 0.05);
if (Pitch > 0.5) Pitch = 0.5f;
if (Pitch < -0.5) Pitch = -0.5f;
//Flat
Vector desired = UtilAlg.getTrajectory2d(Location, Target);
desired.subtract(UtilAlg.Normalize(new Vector(Velocity.getX(), 0, Velocity.getZ())));
desired.multiply(0.075);
Velocity.add(desired);
//Speed
UtilAlg.Normalize(Velocity);
}
public void Target()
{
if (TargetEntity != null)
{
if (!TargetEntity.isValid())
{
TargetEntity = null;
}
else
{
Target = TargetEntity.getLocation().subtract(0, 8, 0);
}
return;
}
if (Target == null)
{
TargetSky();
}
if (UtilMath.offset(Location, Target) < 4)
{
//Target Player
if (Target.getY() >= Host.GetSpectatorLocation().getY())
{
TargetPlayer();
}
//Target Sky
else
{
TargetSky();
}
}
TargetTimeout();
}
public void TargetTimeout()
{
if (UtilMath.offset(Location, Target)+1 < RangeBest)
{
RangeTime = System.currentTimeMillis();
RangeBest = UtilMath.offset(Location, Target);
}
else
{
if (UtilTime.elapsed(RangeTime, 10000))
{
TargetSky();
}
}
}
public void TargetSky()
{
RangeBest = 9000;
RangeTime = System.currentTimeMillis();
Target = Host.GetSpectatorLocation().clone().add(50 - UtilMath.r(100), 20 + UtilMath.r(30), 50 - UtilMath.r(100));
}
public void TargetPlayer()
{
RangeBest = 9000;
RangeTime = System.currentTimeMillis();
Player player = Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size()));
Target = player.getLocation();
Target.add(UtilAlg.getTrajectory(Location, Target).multiply(4));
}
public void HitByArrow()
{
TargetSky();
}
}

View File

@ -148,6 +148,7 @@ public class Dragons extends SoloGame
EnderDragon dragon = location.getWorld().spawn(location, EnderDragon.class);
UtilEnt.vegetate(dragon);
UtilEnt.ghost(dragon, true, false);
location.getWorld().playSound(location, Sound.ENDERDRAGON_GROWL, 20f, 1f);

View File

@ -1,13 +1,11 @@
package nautilus.game.arcade.game.games.squidshooters;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Location;
@ -54,8 +52,7 @@ import nautilus.game.arcade.kit.Kit;
public class SquidShooters extends SoloGame
{
private static final int KILLS_TO_WIN = 5;
private static final int MAX_DISPLAY = 14;
private static final int KILLS_TO_WIN = 20;
private static final String[] DESCRIPTION =
{
"Hold " + C.cYellow + "Sneak" + C.Reset + " to swim.",
@ -64,7 +61,7 @@ public class SquidShooters extends SoloGame
"First squid to " + C.cYellow + KILLS_TO_WIN + C.Reset + " kills wins."
};
private final Map<UUID, Integer> _kills = new HashMap<>();
private final Map<Player, Integer> _kills = new HashMap<>();
private final Set<Player> _inAir = new HashSet<>();
public SquidShooters(ArcadeManager manager)
@ -97,21 +94,9 @@ public class SquidShooters extends SoloGame
Scoreboard.writeNewLine();
List<Player> alive = GetPlayers(true);
if (alive.size() > MAX_DISPLAY)
Scoreboard.writeGroup(_kills.keySet(), player ->
{
alive = new ArrayList<>(alive);
while (alive.size() > MAX_DISPLAY)
{
alive.remove(alive.size() - 1);
}
}
Scoreboard.writeGroup(alive, player ->
{
Integer kills = _kills.get(player.getUniqueId());
Integer kills = _kills.get(player);
return kills == null ? null : Pair.create(C.cGreen + player.getName(), kills);
}, true);
@ -123,8 +108,6 @@ public class SquidShooters extends SoloGame
{
Player player = event.GetPlayer();
player.setWalkSpeed(0.05F);
DisguiseSquid disguise = new DisguiseSquid(player);
disguise.setName(getPlayersTeam().GetColor() + player.getName());
disguise.setCustomNameVisible(true);
@ -260,12 +243,19 @@ public class SquidShooters extends SoloGame
{
CombatComponent killer = event.GetLog().GetKiller();
if (killer == null || !killer.IsPlayer())
if (killer == null)
{
return;
}
_kills.compute(killer.getUniqueIdOfEntity(), (k, v) -> _kills.getOrDefault(k, 0) + 1);
Player killerPlayer = UtilPlayer.searchExact(killer.getUniqueIdOfEntity());
if (killerPlayer == null)
{
return;
}
_kills.compute(killerPlayer, (k, v) -> _kills.getOrDefault(k, 0) + 1);
}
@EventHandler
@ -273,14 +263,14 @@ public class SquidShooters extends SoloGame
{
Player player = event.getPlayer();
_kills.remove(player.getUniqueId());
_kills.remove(player);
_inAir.remove(player);
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void damage(CustomDamageEvent event)
{
if (!IsLive())
if (!IsLive() || event.IsCancelled())
{
return;
}
@ -288,6 +278,14 @@ public class SquidShooters extends SoloGame
if (event.GetCause() == DamageCause.ENTITY_ATTACK)
{
event.SetCancelled("Squid Melee Attack");
return;
}
Player damagee = event.GetDamageePlayer();
if (damagee != null)
{
damagee.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 8, 0, false, false), true);
}
}
@ -324,7 +322,7 @@ public class SquidShooters extends SoloGame
}
List<Player> places = alive.stream()
.sorted(Comparator.comparing(player -> _kills.getOrDefault(((Player) player).getUniqueId(), 0)).reversed())
.sorted(Comparator.comparing(player -> _kills.getOrDefault(player, 0)).reversed())
.collect(Collectors.toList());
if (!places.isEmpty())
@ -343,22 +341,4 @@ public class SquidShooters extends SoloGame
AnnounceEnd(places);
SetState(GameState.End);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void preventMovement(CustomDamageEvent event)
{
if (!IsLive())
{
return;
}
Player damagee = event.GetDamageePlayer();
if (event.IsCancelled() || damagee == null)
{
return;
}
damagee.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 15, 0, false, false), true);
}
}

View File

@ -1,8 +1,5 @@
package nautilus.game.arcade.game.games.squidshooters.kit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -18,7 +15,6 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
@ -66,7 +62,7 @@ public class KitRetroSquid extends Kit
ItemStack itemStack = player.getItemInHand();
Block block = event.getClickedBlock();
if (!HasKit(player) || !UtilItem.isAxe(itemStack) || UtilBlock.usable(block) || !Recharge.Instance.use(player, NAME, 1000, false, true))
if (!HasKit(player) || !UtilItem.isAxe(itemStack) || UtilBlock.usable(block) || !Recharge.Instance.use(player, NAME, 1200, false, true))
{
return;
}
@ -91,11 +87,6 @@ public class KitRetroSquid extends Kit
from = closet.getLocation();
UtilFirework.playFirework(from.clone().add(0, 1, 0), FireworkEffect.builder()
.with(Type.BALL_LARGE)
.withColor(Color.AQUA)
.build());
UtilPlayer.getInRadius(from, 2).forEach((hit, scale) ->
{
if (player.equals(hit))
@ -103,7 +94,8 @@ public class KitRetroSquid extends Kit
return;
}
Manager.GetDamage().NewDamageEvent(hit, player, null, DamageCause.CUSTOM, 15 * scale, true, true, true, player.getName(), NAME);
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
Manager.GetDamage().NewDamageEvent(hit, player, null, DamageCause.CUSTOM, 7 * scale, true, true, true, player.getName(), NAME);
});
break;

View File

@ -0,0 +1,465 @@
package nautilus.game.arcade.game.games.tug;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Cow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.tug.entities.TugCow;
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.KitTugLeaper;
import nautilus.game.arcade.game.games.tug.kits.KitTugSmasher;
import nautilus.game.arcade.kit.Kit;
public class TugOfWool extends TeamGame
{
private static final String[] DESCRIPTION =
{
"Your animals are " + C.cRed + "Hungry" + C.Reset + ".",
"Guide them to " + C.cYellow + "Enemy Crops" + C.Reset + ".",
"Eat " + C.cAqua + "All" + C.Reset + " enemy crops to win!"
};
private static final int MAX_ANIMALS = 30;
private static final long INCREASE_TIME = TimeUnit.MINUTES.toMillis(2);
private static final long GAME_TIMEOUT = TimeUnit.MINUTES.toMillis(10);
private final Set<TugTeam> _teams;
private float _speed = 1;
private int _animalsPerIteration = 1;
private long _lastIncrease;
public TugOfWool(ArcadeManager manager)
{
super(manager, GameType.Tug, new Kit[]
{
new KitTugArcher(manager),
new KitTugSmasher(manager),
new KitTugLeaper(manager)
}, DESCRIPTION);
_teams = new HashSet<>();
DamageFall = false;
DeathOut = false;
DeathSpectateSecs = 5;
registerChatStats(
Kills,
Deaths,
BlankLine,
DamageDealt,
DamageTaken
);
}
@Override
public void ParseData()
{
TugTeam red = new TugTeam(GetTeam(ChatColor.RED), setupCrops("RED"));
TugTeam blue = new TugTeam(GetTeam(ChatColor.AQUA), setupCrops("BLUE"));
red.setEnemy(blue);
blue.setEnemy(red);
_teams.add(red);
_teams.add(blue);
}
private List<Location> setupCrops(String key)
{
List<Location> crops = WorldData.GetDataLocs(key);
crops.forEach(location ->
{
Block block = location.getBlock();
block.getRelative(BlockFace.DOWN).setType(Material.SOIL);
block.setType(Material.CROPS);
block.setData((byte) 7);
});
return crops;
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
_lastIncrease = System.currentTimeMillis();
}
@EventHandler
public void update(UpdateEvent event)
{
if (!IsLive())
{
return;
}
switch (event.getType())
{
case TICK:
updateTargets();
break;
case SEC:
updateSpawns();
break;
}
}
private void updateSpawns()
{
CreatureAllowOverride = true;
boolean cow = Math.random() < 0.01;
if (cow)
{
Announce(F.main(getArcadeManager().getName(), F.name("Bob The Cow") + " has spawned for both teams!"));
}
_teams.forEach(team ->
{
for (int i = 0; i < _animalsPerIteration && team.getEntities().size() < MAX_ANIMALS; i++)
{
team.getEntities().add(new TugSheep(this, spawnEntity(team, Sheep.class)));
}
if (cow)
{
LivingEntity entity = spawnEntity(team, Cow.class);
entity.setMaxHealth(60);
entity.setHealth(entity.getMaxHealth());
entity.setCustomName(C.cYellowB + "Bob The Cow");
entity.setCustomNameVisible(true);
entity.getWorld().playSound(entity.getLocation(), Sound.COW_IDLE, 2, 1);
team.getEntities().add(new TugCow(this, entity));
}
});
CreatureAllowOverride = false;
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!"));
_speed *= 1.1;
_animalsPerIteration++;
DeathSpectateSecs++;
_lastIncrease = System.currentTimeMillis();
}
}
private <T extends LivingEntity> T spawnEntity(TugTeam team, Class<T> classOfEntity)
{
Location location = UtilAlg.Random(team.getSpawns());
if (location == null)
{
location = GetSpectatorLocation();
}
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation())));
T entity = location.getWorld().spawn(location, classOfEntity);
UtilEnt.vegetate(entity);
UtilEnt.setTickWhenFarAway(entity, true);
if (entity instanceof Sheep)
{
((Sheep) entity).setColor(team.getGameTeam().getDyeColor());
}
return entity;
}
private void updateTargets()
{
_teams.forEach(team ->
{
List<Location> targetCrops = team.getEnemy().getCrops();
List<TugSheep> targetEntities = team.getEnemy().getEntities();
team.getEntities().removeIf(tugEntity ->
{
if (!tugEntity.getEntity().isValid())
{
return true;
}
LivingEntity targetEntity = tugEntity.getTargetEntity();
// Has a target entity
if (targetEntity != null)
{
if (!targetEntity.isValid())
{
tugEntity.setTargetEntity(null);
}
// Attempt to attack it, if unsuccessful move closer
if (!tugEntity.attemptAttack(targetEntity))
{
tugEntity.move();
}
return false;
}
Location targetLocation = tugEntity.getTargetLocation();
for (TugSheep otherTugEntity : targetEntities)
{
// Attempt to target entity. If successful no need to handle anything else
if (tugEntity.attemptTarget(otherTugEntity.getEntity()))
{
return false;
}
}
// No target crop or crop no longer exists
if (targetLocation == null || !targetCrops.contains(targetLocation))
{
Location closest = UtilAlg.findClosest(tugEntity.getEntity().getLocation(), targetCrops);
if (closest == null)
{
return false;
}
tugEntity.setTargetLocation(closest);
}
else if (tugEntity.attemptEat())
{
targetCrops.remove(targetLocation);
return true;
}
// Finally move the entity closer to it's target
tugEntity.move();
return false;
});
});
}
@EventHandler(priority = EventPriority.HIGH)
public void damage(CustomDamageEvent event)
{
if (event.IsCancelled())
{
return;
}
Player damager = event.GetDamagerPlayer(true);
if (damager == null)
{
return;
}
TugTeam team = getTugTeam(damager);
if (team == null || !team.isEntity(event.GetDamageeEntity()))
{
return;
}
event.SetCancelled("Own Tug Entity");
}
@EventHandler
public void entityDeath(EntityDeathEvent event)
{
if (!IsLive())
{
return;
}
event.getDrops().clear();
_teams.forEach(team -> team.getEntities().removeIf(entity -> entity.getEntity().equals(event.getEntity())));
}
@EventHandler(ignoreCancelled = true)
public void entityTarget(EntityTargetEvent event)
{
if (!IsLive())
{
return;
}
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void cropTrample(EntityChangeBlockEvent event)
{
if (!IsLive())
{
return;
}
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void cropTrample(EntityInteractEvent event)
{
if (!IsLive() || event.getBlock() == null || event.getBlock().getType() != Material.SOIL)
{
return;
}
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void cropTrample(PlayerInteractEvent event)
{
if (!IsLive() || event.getClickedBlock() == null || event.getClickedBlock().getRelative(BlockFace.DOWN).getType() != Material.SOIL)
{
return;
}
event.setCancelled(true);
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !InProgress())
{
return;
}
Scoreboard.writeNewLine();
_teams.forEach(team ->
{
Scoreboard.write(team.getGameTeam().GetFormattedName());
Scoreboard.write(team.getCrops().size() + " Wheat Left");
Scoreboard.writeNewLine();
});
if (IsLive())
{
Scoreboard.write(C.cYellowB + "Time Left");
Scoreboard.write(UtilTime.MakeStr(Math.max(0, GetStateTime() + GAME_TIMEOUT - System.currentTimeMillis())));
Scoreboard.writeNewLine();
}
Scoreboard.draw();
}
@Override
public void EndCheck()
{
if (!IsLive())
{
return;
}
GameTeam winner = null;
if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT))
{
int mostCrops = 0;
for (TugTeam team : _teams)
{
int crops = team.getCrops().size();
if (crops > mostCrops)
{
winner = team.getGameTeam();
mostCrops = crops;
}
}
}
else
{
for (TugTeam team : _teams)
{
if (team.getCrops().isEmpty())
{
winner = team.getEnemy().getGameTeam();
break;
}
}
}
if (winner != null)
{
AnnounceEnd(winner);
SetState(GameState.End);
}
}
public TugTeam getTugTeam(Player player)
{
for (TugTeam other : _teams)
{
if (other.getGameTeam().HasPlayer(player))
{
return other;
}
}
return null;
}
public float getSpeed()
{
return _speed;
}
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/speed"))
{
String[] args = event.getMessage().split(" ");
_speed = Float.parseFloat(args[1]);
}
}
}

View File

@ -0,0 +1,71 @@
package nautilus.game.arcade.game.games.tug;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.tug.entities.TugSheep;
public class TugTeam
{
private final GameTeam _gameTeam;
private final List<Location> _crops, _spawns;
private final List<TugSheep> _entities;
private TugTeam _enemy;
TugTeam(GameTeam gameTeam, List<Location> crops)
{
_gameTeam = gameTeam;
_crops = new ArrayList<>(crops);
_spawns = new ArrayList<>(crops);
_entities = new ArrayList<>();
}
public GameTeam getGameTeam()
{
return _gameTeam;
}
public List<Location> getCrops()
{
return _crops;
}
public List<Location> getSpawns()
{
return _spawns;
}
public List<TugSheep> getEntities()
{
return _entities;
}
public boolean isEntity(LivingEntity entity)
{
for (TugSheep tugEntity : getEntities())
{
if (tugEntity.getEntity().equals(entity))
{
return true;
}
}
return false;
}
public void setEnemy(TugTeam enemy)
{
_enemy = enemy;
}
public TugTeam getEnemy()
{
return _enemy;
}
}

View File

@ -0,0 +1,43 @@
package nautilus.game.arcade.game.games.tug.entities;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import nautilus.game.arcade.game.games.tug.TugOfWool;
public class TugCow extends TugSheep
{
public TugCow(TugOfWool host, LivingEntity entity)
{
super(host, entity);
}
@Override
public void attack(LivingEntity other)
{
UtilEnt.getInRadius(other.getLocation(), 3).forEach((entity, scale) ->
{
if (getEntity().equals(entity))
{
return;
}
Vector velocity = UtilAlg.getTrajectory(entity, getEntity())
.setY(0.8)
.multiply(scale);
other.getWorld().playEffect(other.getLocation().add(0, 1, 0), Effect.STEP_SOUND, Material.GRASS);
UtilAction.velocity(entity, velocity);
});
setTargetEntity(null);
}
}

View File

@ -0,0 +1,15 @@
package nautilus.game.arcade.game.games.tug.entities;
import org.bukkit.entity.LivingEntity;
import nautilus.game.arcade.game.games.tug.TugOfWool;
public abstract class TugEntity<T extends LivingEntity>
{
private final TugOfWool _host;
private final T _entity;
public abstract void attack(LivingEntity other);
}

View File

@ -0,0 +1,9 @@
package nautilus.game.arcade.game.games.tug.entities;
public enum TugEntityType
{
SHEEP,
COW
}

View File

@ -0,0 +1,136 @@
package nautilus.game.arcade.game.games.tug.entities;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
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.UtilTime;
import nautilus.game.arcade.game.games.tug.TugOfWool;
public class TugSheep
{
private static final int ATTACK_RATE = 500;
private static final int ATTACK_RANGE_SQUARED = 9;
private static final int TARGET_RANGE_SQUARED = 64;
private static final int EAT_RANGE_SQUARED = 2;
private final TugOfWool _host;
private final LivingEntity _entity;
private Location _targetLocation;
private LivingEntity _targetEntity;
private long _lastAttack;
public TugSheep(TugOfWool host, LivingEntity entity)
{
_host = host;
_entity = entity;
}
public boolean attemptAttack(LivingEntity other)
{
if (!UtilTime.elapsed(_lastAttack, ATTACK_RATE) || UtilMath.offsetSquared(_entity, other) > ATTACK_RANGE_SQUARED)
{
return false;
}
_lastAttack = System.currentTimeMillis();
attack(other);
return true;
}
public void attack(LivingEntity other)
{
other.damage(4 + Math.random(), _entity);
}
public boolean attemptTarget(LivingEntity other)
{
if (UtilMath.offsetSquared(_entity, other) < TARGET_RANGE_SQUARED)
{
setTargetEntity(other);
return true;
}
return false;
}
public boolean attemptEat()
{
Location entityLocation = _entity.getLocation();
if (_targetLocation == null || UtilMath.offsetSquared(entityLocation, _targetLocation) > EAT_RANGE_SQUARED)
{
return false;
}
Block block = _targetLocation.getBlock();
UtilParticle.PlayParticleToAll(ParticleType.HEART, entityLocation.add(0, 1, 0), 1, 1, 1, 0, 6, ViewDist.NORMAL);
_targetLocation.getWorld().playSound(entityLocation, Sound.EAT, 1.5F, (float) Math.random());
_targetLocation.getWorld().playEffect(_targetLocation, Effect.STEP_SOUND, block.getType());
block.setType(Material.AIR);
_entity.remove();
return true;
}
public void move()
{
Location location;
if (_targetEntity != null)
{
location = _targetEntity.getLocation();
}
else if (_targetLocation != null)
{
location = _targetLocation;
}
else
{
return;
}
Vector direction = UtilAlg.getTrajectory(_entity.getLocation(), location)
.multiply(_host.getSpeed());
UtilEnt.CreatureMoveFast(_entity, location.clone().add(direction), _host.getSpeed());
}
public void setTargetLocation(Location targetLocation)
{
_targetLocation = targetLocation;
}
public Location getTargetLocation()
{
return _targetLocation;
}
public void setTargetEntity(LivingEntity targetEntity)
{
_targetEntity = targetEntity;
}
public LivingEntity getTargetEntity()
{
return _targetEntity;
}
public LivingEntity getEntity()
{
return _entity;
}
}

View File

@ -0,0 +1,62 @@
package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemBuilder;
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.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
public class KitTugArcher extends Kit
{
private static final ItemStack[] PLAYER_ITEMS =
{
new ItemBuilder(Material.STONE_SWORD)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.BOW)
.setUnbreakable(true)
.build()
};
private static final ItemStack[] PLAYER_ARMOUR =
{
new ItemBuilder(Material.CHAINMAIL_BOOTS)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.CHAINMAIL_LEGGINGS)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.CHAINMAIL_CHESTPLATE)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.CHAINMAIL_HELMET)
.setUnbreakable(true)
.build()
};
private static final Perk[] PERKS =
{
new PerkFletcher(3, 3, true),
new PerkBarrage(8, 150, true, false, true)
};
public KitTugArcher(ArcadeManager manager)
{
super(manager, GameKit.TUG_ARCHER, PERKS);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(PLAYER_ARMOUR);
}
}

View File

@ -0,0 +1,58 @@
package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
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
{
private static final ItemStack[] PLAYER_ITEMS =
{
new ItemBuilder(Material.IRON_AXE)
.setUnbreakable(true)
.build()
};
private static final ItemStack[] PLAYER_ARMOUR =
{
new ItemBuilder(Material.GOLD_BOOTS)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.GOLD_LEGGINGS)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.GOLD_CHESTPLATE)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.GOLD_HELMET)
.setUnbreakable(true)
.build()
};
private static final Perk[] PERKS =
{
new PerkLeap("Leap", 1.1, 0.9, 3000)
};
public KitTugLeaper(ArcadeManager manager)
{
super(manager, GameKit.TUG_LEAPER, PERKS);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(PLAYER_ARMOUR);
}
}

View File

@ -0,0 +1,59 @@
package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemBuilder;
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.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import nautilus.game.arcade.kit.perks.PerkMammoth;
public class KitTugSmasher extends Kit
{
private static final ItemStack[] PLAYER_ITEMS =
{
new ItemBuilder(Material.IRON_SWORD)
.setUnbreakable(true)
.build()
};
private static final ItemStack[] PLAYER_ARMOUR =
{
new ItemBuilder(Material.IRON_BOOTS)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.IRON_LEGGINGS)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.IRON_CHESTPLATE)
.setUnbreakable(true)
.build(),
new ItemBuilder(Material.IRON_HELMET)
.setUnbreakable(true)
.build()
};
private static final Perk[] PERKS =
{
new PerkMammoth()
};
public KitTugSmasher(ArcadeManager manager)
{
super(manager, GameKit.TUG_SMASHER, PERKS);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(PLAYER_ARMOUR);
}
}

View File

@ -13,6 +13,7 @@ import mineplex.core.common.util.C;
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponent;
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
import nautilus.game.arcade.stats.ExperienceStatTracker;
public class ExperienceSummaryComponent extends GameSummaryComponent<Pair<AchievementLog, AchievementData>>
{
@ -35,7 +36,7 @@ public class ExperienceSummaryComponent extends GameSummaryComponent<Pair<Achiev
return null;
}
return C.cGray + "+" + C.cYellow + data.getLeft().Amount + C.cGray + " Experience";
return C.cGray + "+" + C.cYellow + data.getLeft().Amount + C.cGray + " Experience" + (ExperienceStatTracker.DOUBLE_EXP ? C.cGoldB + " DOUBLE EXP" : "");
}
@Override

View File

@ -1203,7 +1203,7 @@ public class GameFlagManager implements Listener
}
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOW)
public void WorldSoilTrample(PlayerInteractEvent event)
{
if (event.getAction() != Action.PHYSICAL)

View File

@ -235,7 +235,8 @@ public abstract class LobbyManager implements Listener
else if (event.getType() == UpdateType.FASTEST)
{
UpdateFirework();
PlayerSelector.selectPlayers(UtilLambda.and(PlayerSelector.inWorld(WORLD), UtilLambda.not(PlayerSelector.within(getSpawn(), 100))))
// TODO TEMPORARY INCREASE 100 -> 200. ALLOW CUSTOM BORDERS WHEN IF REWRITTEN
PlayerSelector.selectPlayers(UtilLambda.and(PlayerSelector.inWorld(WORLD), UtilLambda.not(PlayerSelector.within(getSpawn(), 200))))
.forEach(player -> player.teleport(getSpawn()));
}
else if (event.getType() == UpdateType.SLOW)

View File

@ -1,6 +1,8 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -11,14 +13,17 @@ import mineplex.core.common.util.NautHashMap;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GemData;
public class ExperienceStatTracker extends StatTracker<Game>
{
public static final boolean DOUBLE_EXP = true;
private long _startTime = -1;
private NautHashMap<String, Long> _playerQuitTime = new NautHashMap<String, Long>();
private final Map<String, Long> _playerQuitTime = new HashMap<>();
public ExperienceStatTracker(Game game)
{
super(game);
@ -27,84 +32,83 @@ public class ExperienceStatTracker extends StatTracker<Game>
@EventHandler
public void onGameStart(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.Live)
if (event.GetState() == GameState.Live)
{
_startTime = System.currentTimeMillis();
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
_playerQuitTime.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameEnd(GameStateChangeEvent event)
{
if (!event.GetGame().Manager.IsRewardStats() || !event.GetGame().Manager.IsRewardAchievements())
return;
if (_startTime <= 0)
return;
if (event.GetState() == Game.GameState.End)
if (!event.GetGame().Manager.IsRewardStats() || !event.GetGame().Manager.IsRewardAchievements() || event.GetState() != GameState.End || _startTime <= 0)
{
List<Player> winners = getGame().getWinners();
if (winners != null)
{
for (Player player : event.GetGame().GetPlayers(false))
{
//Tally Gems
double gemExp = 0;
for (String reason : event.GetGame().GetGems(player).keySet())
{
if (reason.toLowerCase().contains("participation"))
continue;
GemData gem = event.GetGame().GetGems(player).get(reason);
gemExp += (int)gem.Gems;
}
gemExp = Math.min(gemExp, 250) * 6;
//Game Time = 1 Exp per 3 Seconds
long time = System.currentTimeMillis();
long playerJoin = getGame().getPlayerIngameTime(player);
if (playerJoin == 0)
playerJoin = _startTime;
//Exp Until They Quit
if (!player.isOnline())
{
if (_playerQuitTime.containsKey(player.getName()))
{
time = _playerQuitTime.get(player.getName());
}
else
{
time = _startTime;
}
}
double timeExp = (time - playerJoin)/1500d;
//Mult
double mult = 1;
if (winners.contains(player))
mult = 1.5;
//Exp
int expGained = (int)(((timeExp + gemExp)*mult)*getGame().XpMult);
// Kit Exp
event.GetGame().getArcadeManager().getMineplexGameManager().getKitStatLog().get(player).setExperienceEarned(expGained);
//Record Global and per Game
addStat(player, "ExpEarned", expGained, false, true);
addStat(player, "ExpEarned", expGained, false, false);
}
}
_startTime = -1;
return;
}
List<Player> winners = getGame().getWinners();
if (winners != null)
{
for (Player player : event.GetGame().GetPlayers(false))
{
//Tally Gems
double gemExp = 0;
for (String reason : event.GetGame().GetGems(player).keySet())
{
if (reason.toLowerCase().contains("participation"))
continue;
GemData gem = event.GetGame().GetGems(player).get(reason);
gemExp += (int) gem.Gems;
}
gemExp = Math.min(gemExp, 250) * 6;
//Game Time = 1 Exp per 3 Seconds
long time = System.currentTimeMillis();
long playerJoin = getGame().getPlayerIngameTime(player);
if (playerJoin == 0)
playerJoin = _startTime;
//Exp Until They Quit
if (!player.isOnline())
{
time = _playerQuitTime.getOrDefault(player.getName(), _startTime);
}
double timeExp = (time - playerJoin) / 1500d;
//Mult
double mult = 1;
if (winners.contains(player))
{
mult = 1.5;
}
if (DOUBLE_EXP)
{
mult *= 2;
}
//Exp
int expGained = (int) (((timeExp + gemExp) * mult) * getGame().XpMult);
// Kit Exp
event.GetGame().getArcadeManager().getMineplexGameManager().getKitStatLog().get(player).setExperienceEarned(expGained);
//Record Global and per Game
addStat(player, "ExpEarned", expGained, false, true);
addStat(player, "ExpEarned", expGained, false, false);
}
}
_startTime = -1;
}
}

View File

@ -62,10 +62,9 @@ public class WorldData
public WorldData(Game game)
{
Host = game;
Id = GetNewId();
Initialize();
Id = GetNewId();
}
public void Initialize()
@ -98,7 +97,6 @@ public class WorldData
creator.generator(new WorldGenCleanRoom());
World = WorldUtil.LoadWorld(creator);
TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD);
@ -407,7 +405,7 @@ public class WorldData
}
}
int id = 0;
int id;
//Read
try