Merge branch 'clans/beta' of github.com:Mineplex-LLC/Minecraft-PC into clans/beta

This commit is contained in:
phobia 2016-03-30 23:01:55 +11:00
commit 978f978023
9 changed files with 175 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Stream;
@ -612,4 +613,13 @@ public class UtilAlg
return new Location(location.getWorld(), x, location.getY(), z, location.getYaw(), location.getPitch());
}
public static Location getRandomLocation(Location center, int radius)
{
Random r = new Random();
int x = r.nextInt(radius * 2) - radius;
int y = r.nextInt(radius * 2) - radius;
int z = r.nextInt(radius * 2) - radius;
return center.clone().add(x, y, z);
}
}

View File

@ -1,10 +1,13 @@
package mineplex.game.clans.clans.siege.weapon;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
@ -20,6 +23,7 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
@ -32,6 +36,7 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
@ -405,5 +410,36 @@ public class Cannon extends SiegeWeapon
return new double[] { yAdd, hMult };
}
@EventHandler
public void explosionEffects(SiegeWeaponExplodeEvent event)
{
for (int i = 0; i < 8; i++)
{
// Explosion particle effects.
Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
}
// Block explosion.
ArrayList<Block> blocks = new ArrayList<>();
int attempts = 0;
while (blocks.size() < 10 && (attempts < 30))
{
Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock();
if ((block.getType() != Material.AIR) && (!blocks.contains(block)))
{
blocks.add(block);
}
attempts++;
}
_siegeManager.getClansManager().getExplosion().BlockExplosion(
blocks,
event.getProjectile().getLocation(),
false
);
}
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -18,6 +20,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
@ -163,6 +167,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
System.out.println(String.format("Tutorial> [%s] finished tutorial [%s]", player.getName(), getName()));
playFinishEffects(player.getLocation());
onFinish(player);
}
@ -295,4 +300,28 @@ public abstract class Tutorial implements Listener, ObjectiveListener
{
return _playerSessionMap.get(player);
}
private void playFinishEffects(Location location)
{
// Firework
UtilFirework.launchFirework(
location,
FireworkEffect.Type.STAR,
Color.GREEN,
true,
true,
null,
1
);
// Particles
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER,
location, 0.5F, 0.5F, 0.5F, 1, 3, UtilParticle.ViewDist.LONG);
UtilParticle.PlayParticle(UtilParticle.ParticleType.ENCHANTMENT_TABLE,
location, 0.5F, 0.5F, 0.5F, 1, 3, UtilParticle.ViewDist.LONG);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART,
location, 0.5F, 0.5F, 0.5F, 1, 3, UtilParticle.ViewDist.LONG);
UtilParticle.PlayParticle(UtilParticle.ParticleType.NOTE,
location, 0.5F, 0.5F, 0.5F, 1, 3, UtilParticle.ViewDist.LONG);
}
}

View File

@ -2,6 +2,7 @@ package mineplex.game.clans.tutorial.tutorials.clans;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.bukkit.DyeColor;
import org.bukkit.GameMode;
@ -47,6 +48,9 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
public class ClansMainTutorial extends Tutorial
{
// The distance from which the gate opens when a player approaches.
private static final int GATE_OPEN_DISTANCE = 15;
private TutorialMapManager _mapManager;
// private TutorialRepository _repository;
@ -352,6 +356,24 @@ public class ClansMainTutorial extends Tutorial
*/
}
public void performGateCheck(Player player, DyeColor key)
{
Location exact = getRegion(player).getLocationMap().getIronLocations(key).get(0);
Location fence = UtilAlg.getAverageLocation(getRegion(player).getLocationMap().getIronLocations(key));
if (exact.getBlock().getType() == Material.AIR)
{
// Gates are already open.
return;
}
if (player.getLocation().distanceSquared(fence) <= (GATE_OPEN_DISTANCE * 2))
{
// Within the correct blocks of the gates.
destroyFences(getRegion(player), key);
}
}
public TutorialMapManager getMapManager()
{
return _mapManager;

View File

@ -67,7 +67,6 @@ public class ShopsObjective extends OrderedObjective<ClansMainTutorial>
super.customStart(player);
TutorialRegion region = getPlugin().getRegion(player);
getPlugin().destroyFences(region, DyeColor.BROWN);
ArrayList<Npc> npcs = new ArrayList<>();

View File

@ -33,7 +33,10 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
@Override
protected void clean(Player player, TutorialRegion region)
{
getObjective().getCannons().remove(player.getName()).kill();
// This cannon could be removed from the tutorial already in BlowUpWallGoal, we need to check if its null
Cannon cannon = getObjective().getCannons().remove(player.getName());
if (cannon != null)
cannon.kill();
}
@Override

View File

@ -3,9 +3,12 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields;
import java.util.UUID;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilAlg;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
@ -23,8 +26,6 @@ public class GoToFieldsGoal extends ObjectiveGoal<FieldsObjective>
@Override
protected void customStart(Player player)
{
// Open middle gate
getObjective().getPlugin().destroyFences(getObjective().getPlugin().getRegion(player), DyeColor.RED);
}
@Override
@ -32,6 +33,20 @@ public class GoToFieldsGoal extends ObjectiveGoal<FieldsObjective>
{
}
@EventHandler
public void openGates(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
{
return;
}
for (UUID uuid : getActivePlayers())
{
getObjective().getPlugin().performGateCheck(UtilPlayer.searchExact(uuid), DyeColor.RED);
}
}
@EventHandler
public void checkRegion(UpdateEvent event)
{

View File

@ -3,6 +3,11 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.finalobj;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.delayedtask.DelayedTaskClient;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.tutorial.objective.Objective;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
@ -40,10 +45,40 @@ public class TpClanHomeGoal extends ObjectiveGoal<FinalObjective>
{
return;
}
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have teleported to your Clan's Home."));
event.getPlayer().teleport(getObjective().getPlugin().getTutorialSession(event.getPlayer()).getHomeLocation());
finish(event.getPlayer());
DelayedTask.Instance.doDelay(
event.getPlayer(),
"Tutorial Home Teleport",
new Callback<DelayedTaskClient>()
{
@Override
public void run(DelayedTaskClient data)
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have teleported to your Clan's Home."));
event.getPlayer().teleport(getObjective().getPlugin().getTutorialSession(event.getPlayer()).getHomeLocation());
finish(event.getPlayer());
}
},
new Callback<DelayedTaskClient>()
{
@Override
public void run(DelayedTaskClient data)
{
UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.time(UtilTime.MakeStr(Math.max(0, data.getTimeLeft("Tutorial Home Teleport")))), 0, 5, 0, data.getPlayer());
}
},
new Callback<DelayedTaskClient>()
{
@Override
public void run(DelayedTaskClient data)
{
UtilPlayer.message(data.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement."));
}
},
15 * 1000, // 15 second cooldown
false
);
event.setCancelled(true);
}
}

View File

@ -2,9 +2,13 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.shops;
import java.util.UUID;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilAlg;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
@ -31,6 +35,20 @@ public class GoToShopsGoal extends ObjectiveGoal<ShopsObjective>
}
@EventHandler
public void openGates(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
{
return;
}
for (UUID uuid : getActivePlayers())
{
getObjective().getPlugin().performGateCheck(UtilPlayer.searchExact(uuid), DyeColor.BROWN);
}
}
@EventHandler
public void checkRegion(UpdateEvent event)
{