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

This commit is contained in:
Ben 2016-03-31 00:03:12 +01:00
commit 36caf16c9a
30 changed files with 476 additions and 130 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

@ -601,7 +601,17 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
if (event.getJoinMessage() != null)
{
event.setJoinMessage(null);
UtilServer.broadcast(F.sys("Join", event.getPlayer().getName()));
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.isInTutorial(other))
{
// Don't display join message if player in tutorial.
continue;
}
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
}
}
}
@ -617,7 +627,17 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
if (event.getQuitMessage() != null)
{
event.setQuitMessage(null);
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.isInTutorial(other))
{
// Don't display quit message if player in tutorial.
continue;
}
other.sendMessage(F.sys("Quit", event.getPlayer().getName()));
}
}
}
@ -633,7 +653,17 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
if (event.getLeaveMessage() != null)
{
event.setLeaveMessage(null);
UtilServer.broadcast(F.sys("Leave", event.getPlayer().getName()));
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.isInTutorial(other))
{
// Don't display leave message if player in tutorial.
continue;
}
other.sendMessage(F.sys("Leave", event.getPlayer().getName()));
}
}
}

View File

@ -55,14 +55,14 @@ public class ClansCommand extends CommandBase<ClansManager>
@Override
public void Execute(Player caller, String[] args)
{
if (UtilServer.CallEvent(new ClansCommandPreExecutedEvent(caller, args)).isCancelled())
return;
if (args == null || args.length == 0)
{
_clansManager.getClanShop().attemptShopOpen(caller);
return;
}
if (UtilServer.CallEvent(new ClansCommandPreExecutedEvent(caller, args)).isCancelled())
return;
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("h"))
help(caller);

View File

@ -18,9 +18,5 @@ public class ClanCreateButton implements IButton
@Override
public void onClick(Player player, ClickType clickType)
{
player.closeInventory();
JsonMessage message = new JsonMessage(C.cRed + C.Bold + "Click here to create a clan").click(ClickEvent.SUGGEST_COMMAND, "/c create ");
message.sendToPlayer(player);
}
}

View File

@ -52,7 +52,7 @@ public class ClanMainPage extends ClanPageBase
public void buildNoClan()
{
// Clan Create
ShopItem clanCreate = new ShopItem(Material.BOOK_AND_QUILL, "Create Clan", new String[] {}, 1, false, false);
ShopItem clanCreate = new ShopItem(Material.BOOK_AND_QUILL, "Create Clan", new String[] {C.cGray + "To create a clan type", C.cRed + "/c create <ClanName>"}, 1, false, false);
addButton(21, clanCreate, new ClanCreateButton());
// Clan Join

View File

@ -222,8 +222,13 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
{
if (time <= unit && !client.InformedTimes.contains(Integer.valueOf(unit)))
{
UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000))));
UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player);
if (!_clansManager.getTutorials().isInTutorial(player))
{
// Only inform if not in tutorial.
UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000))));
UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player);
}
client.InformedTimes.add(Integer.valueOf(unit));
}
}

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);
}
@ -228,7 +233,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
int objectiveIndex = session.getObjectiveIndex();
Objective currentObjective = _objectives.get(objectiveIndex);
lines.add(C.cGoldB + "Current Task (" + (objectiveIndex + 1) + "/" + _objectives.size() + ")");
lines.add(C.cGoldB + (objectiveIndex + 1) + "/" + _objectives.size() + ": " + currentObjective.getName(player));
currentObjective.addScoreboardLines(player, lines);
}
return lines;
@ -275,8 +280,9 @@ public abstract class Tutorial implements Listener, ObjectiveListener
for (Map.Entry<Player, TutorialSession> entry : _playerSessionMap.entrySet())
{
String prefix = entry.getValue().incrementAndGetColorTick() % 2 == 0 ? C.cYellow : C.cGold;
Objective objective = _objectives.get(entry.getValue().getObjectiveIndex());
UtilTextBottom.display(C.cYellow + objective.getDescription(entry.getKey()), entry.getKey());
UtilTextBottom.display(prefix + objective.getDescription(entry.getKey()), entry.getKey());
}
}
@ -294,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

@ -13,6 +13,7 @@ public class TutorialSession
private TutorialRegion _region;
private List<Hologram> _hologramList = new ArrayList<>();
private Location _homeLocation;
private int _colorTick;
public TutorialSession()
{
@ -52,4 +53,9 @@ public class TutorialSession
{
_homeLocation = homeLocation;
}
public int incrementAndGetColorTick()
{
return ++_colorTick;
}
}

View File

@ -56,14 +56,6 @@ public abstract class OrderedObjective<Plugin> extends Objective<Plugin, Ordered
}
}
@Override
public String getName(Player player)
{
OrderedObjectiveData data = getData(player);
int index = data == null ? 0 : data.getIndex();
return _goals.get(index).getName(player);
}
@Override
public String getDescription(Player player)
{

View File

@ -5,6 +5,8 @@ import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
public abstract class SingleObjective<Plugin> extends Objective<Plugin, ObjectiveData>
{
private final ObjectiveData _nullData;
@ -42,9 +44,11 @@ public abstract class SingleObjective<Plugin> extends Objective<Plugin, Objectiv
@Override
public void addScoreboardLines(Player player, List<String> lines)
{
/*
if (contains(player))
{
lines.add(" " + getName(player));
lines.add(" " + C.cRed + getName(player));
}
*/
}
}

View File

@ -55,16 +55,6 @@ public abstract class UnorderedObjective<Plugin> extends Objective<Plugin, Unord
}
}
@Override
public String getName(Player player)
{
// Use first incomplete objective
UnorderedObjectiveData data = getData(player);
if (data == null) return super.getName(player);
int index = data.getFirstIncompleteIndex();
return index == -1 ? super.getName(player) : _goals.get(index).getName(player);
}
@Override
public String getDescription(Player player)
{

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;
@ -41,16 +42,18 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.EnergyObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.LeaveSpawnObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
//import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
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;
// private TutorialRepository _repository;
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager)
{
@ -67,9 +70,8 @@ public class ClansMainTutorial extends Tutorial
_mapManager = new TutorialMapManager(plugin, getWorldManager().getTutorialWorld(), -10, 0, 117, 127);
_repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
// _repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
addObjective(new LeaveSpawnObjective(this, plugin));
addObjective(new ClanObjective(this, plugin));
addObjective(new AttackEnemyObjective(this, plugin));
addObjective(new ShopsObjective(this, npcManager, plugin));
@ -88,7 +90,8 @@ public class ClansMainTutorial extends Tutorial
player.teleport(Spawn.getNorthSpawn());
ClansManager.getInstance().getPvpTimer().unpause(player);
/*
ClansManager.getInstance().runAsync(() -> {
_repository.SetTimesPlayed(player.getUniqueId(), _repository.GetTimesPlayed(player.getUniqueId()) + 1);
@ -107,6 +110,7 @@ public class ClansMainTutorial extends Tutorial
});
}
});
*/
}
@Override
@ -341,12 +345,33 @@ public class ClansMainTutorial extends Tutorial
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
start(event.getPlayer());
/*
ClansManager.getInstance().runAsync(() -> {
if (_repository.GetTimesPlayed(event.getPlayer().getUniqueId()) == 0)
{
ClansManager.getInstance().runSync(() -> start(event.getPlayer()));
}
});
*/
}
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()

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import mineplex.game.clans.clans.siege.weapon.Cannon;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -13,11 +14,18 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.MountCannonGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal;
import java.util.HashMap;
import java.util.Map;
public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
{
private Map<String, Cannon> _cannon;
public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Attack Enemy", "Attack and raid this enemy!");
_cannon = new HashMap<>();
addGoal(new GetMapGoal(this));
addGoal(new HoldItemGoal(this, Material.MAP, "Identify Enemy Clan", "By looking at your map, identify your new enemy"));
@ -36,4 +44,6 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
protected void customFinish(Player player)
{
}
public Map<String, Cannon> getCannons() {return _cannon; }
}

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.*;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -7,11 +8,6 @@ import mineplex.game.clans.tutorial.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.BlowUpWallGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.BuildHouseGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClaimLandGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanDetailsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.CreateClanGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.SetHomeGoal;
public class ClanObjective extends OrderedObjective<ClansMainTutorial>
{
@ -19,8 +15,11 @@ public class ClanObjective extends OrderedObjective<ClansMainTutorial>
{
super(clansMainTutorial, javaPlugin, "Clans", "Create clan with /c create <name>");
addGoal(new LeaveSpawnGoal(this));
addGoal(new CreateClanGoal(this));
addGoal(new ClanManagementGoal(this));
addGoal(new ClanDetailsGoal(this));
addGoal(new ClanInfoGoal(this));
addGoal(new ClaimLandGoal(this));
addGoal(new BuildHouseGoal(this));
addGoal(new SetHomeGoal(this));

View File

@ -1,58 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.objective.SingleObjective;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
public class LeaveSpawnObjective extends SingleObjective<ClansMainTutorial>
{
public LeaveSpawnObjective(ClansMainTutorial plugin, JavaPlugin javaPlugin)
{
super(plugin, javaPlugin, "Leave Spawn", "Exit the tutorial spawn area");
}
@Override
public void setup(Player player, TutorialRegion region)
{
getPlugin().addHologram(player,
getPlugin().getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1, -3),
C.cGoldB + "Welcome to Clans Beta!", C.cWhite + "Walk forward to Start Tutorial");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void checkRegion(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : getActivePlayers())
{
if (!getPlugin().isIn(player, ClansMainTutorial.Bounds.SPAWN))
{
finish(player);
}
}
}
}

View File

@ -7,6 +7,7 @@ import java.util.UUID;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -18,6 +19,7 @@ import mineplex.database.tables.records.NpcsRecord;
import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.HoldItemGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.shops.GoToShopsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.shops.SellPotatoesGoal;
@ -33,6 +35,7 @@ public class ShopsObjective extends OrderedObjective<ClansMainTutorial>
_npcMap = new HashMap<>();
_npcManager = npcManager;
addGoal(new HoldItemGoal(this, Material.MAP, "Identify Shops", "Look at your map and find the shops"));
addGoal(new GoToShopsGoal(this));
addGoal(new SellPotatoesGoal(this));
}
@ -64,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

@ -107,5 +107,6 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
@Override
protected void customFinish(Player player)
{
getObjective().getCannons().remove(player.getName()).kill(); //Kill cannon after goal complete
}
}

View File

@ -18,8 +18,6 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjecti
public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
{
private Map<String, Cannon> _cannon = new HashMap<>();
public MountCannonGoal(AttackEnemyObjective objective)
{
super(objective, "Get on Cannon", "Right click on the Cannon to hop on!");
@ -28,14 +26,17 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
@Override
protected void customStart(Player player)
{
_cannon.put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
_cannon.get(player.getName()).SetForcedVelocity(0.4, 2.45);
getObjective().getCannons().put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45);
}
@Override
protected void clean(Player player, TutorialRegion region)
{
_cannon.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

@ -20,7 +20,7 @@ public class ClaimLandGoal extends ObjectiveGoal<ClanObjective>
{
public ClaimLandGoal(ClanObjective objective)
{
super(objective, "Claim Land", "Claim land with /c claim");
super(objective, "Claim Land", "Claim land by opening the Clan Management page with /c and click the Claim Land Button");
}
@Override

View File

@ -0,0 +1,82 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansPlayer;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import java.sql.Timestamp;
import java.util.UUID;
public class ClanInfoGoal extends ObjectiveGoal<ClanObjective>
{
public ClanInfoGoal(ClanObjective objective)
{
super(objective, "Info on other clan", "Get info on other clans by using the command /c <ClanName>");
}
@Override
protected void customStart(Player player)
{
player.sendMessage(F.main("Clans", "You can use the command /c <ClanName> to get information about other clans. Try typing /c randomClan"));
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onClanInfo(ClansCommandPreExecutedEvent event)
{
if (contains(event.getPlayer()))
{
if(event.getArguments().length < 1) return;
event.setCancelled(true);
event.setCancelled(true);
ClanToken token = new ClanToken();
token.Name = event.getArguments()[0];
token.Description = "Best clan ever!";
token.Home = "";
token.Admin = false;
token.Energy = 4320;
token.Id = UtilMath.random.nextInt(100);
token.Energy = UtilMath.random.nextInt(1000);
token.Kills = UtilMath.random.nextInt(100);
token.Murder = UtilMath.random.nextInt(100);
token.Deaths = UtilMath.random.nextInt(100);
token.WarWins = UtilMath.random.nextInt(100);
token.WarLosses = UtilMath.random.nextInt(100);
token.DateCreated = new Timestamp(System.currentTimeMillis());
token.LastOnline = new Timestamp(System.currentTimeMillis());
ClanInfo clan = new ClanInfo(ClansManager.getInstance(), token);
ClansPlayer chiss = new ClansPlayer("Chiss", UUID.fromString("1d2bfe61-7ebd-445d-ba7d-8354a0ffd1ea"), ClanRole.LEADER);
ClansPlayer jon = new ClansPlayer("defek7", UUID.fromString("89d463f7-23ec-470a-8244-457f0c8d861c"), ClanRole.MEMBER);
chiss.setOnline(true);
jon.setOnline(true);
clan.getMembers().put(chiss.getUuid(), chiss);
clan.getMembers().put(jon.getUuid(), jon);
ClansManager.getInstance().getClanShop().openClanWho(event.getPlayer(), clan);
finish(event.getPlayer());
}
}
}

View File

@ -0,0 +1,45 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import mineplex.core.common.util.F;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
/**
* Created by Adam on 29/03/2016.
*/
public class ClanManagementGoal extends ObjectiveGoal<ClanObjective>
{
public ClanManagementGoal(ClanObjective objective)
{
super(objective, "Manage your clan", "Manage your clan by using the command /c");
}
@Override
protected void customStart(Player player)
{
player.sendMessage(F.main("Clans", "You can use the command /c to manage your clan."));
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onClanInfo(ClansCommandPreExecutedEvent event)
{
if (contains(event.getPlayer()))
{
if (event.getArguments() == null || event.getArguments().length == 0)
{
finish(event.getPlayer());
}
}
}
}

View File

@ -12,7 +12,7 @@ public class CreateClanGoal extends ObjectiveGoal<ClanObjective>
{
public CreateClanGoal(ClanObjective objective)
{
super(objective, "Create a Clan", "Create a Clan");
super(objective, "Create a Clan", "Create a Clan using /c create");
}
@Override

View File

@ -0,0 +1,65 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
{
public LeaveSpawnGoal(ClanObjective objective)
{
super(objective, "Leave Spawn", "Exit the tutorial spawn area");
}
@Override
protected void setup(Player player, TutorialRegion region)
{
getObjective().getPlugin().addHologram(player,
getObjective().getPlugin().getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -6),
C.cGoldB + "Welcome to the Clans Tutorial!",
" ",
"This will teach you the basics of Clans.",
"It will take about 5 minutes to complete.",
"You must complete it before playing Clans.",
" ",
"Walk forward to begin!");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void checkRegion(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (UUID uuid : getActivePlayers())
{
Player player = Bukkit.getPlayer(uuid);
if (!getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.SPAWN))
{
finish(player);
}
}
}
}

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import mineplex.core.common.util.UtilBlock;
import net.minecraft.server.v1_8_R3.EnumDirection;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -35,6 +38,14 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
{
if (getObjective().getPlugin().isIn(event.getPlayer(), ClansMainTutorial.Bounds.LAND_CLAIM))
{
boolean bedPlaced = UtilBlock.placeBed(event.getPlayer().getLocation(), BlockFace.valueOf(EnumDirection.fromAngle(event.getPlayer().getLocation().getYaw()).name()), false, false);
if (!bedPlaced)
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not a suitable place for a bed."));
return;
}
// we need to save this for later when the player teleports home!
getObjective().getPlugin().getTutorialSession(event.getPlayer()).setHomeLocation(event.getPlayer().getLocation());

View File

@ -14,7 +14,7 @@ public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
{
public ExplainEnergyGoal(EnergyObjective objective)
{
super(objective, "About Energy", "About Energy");
super(objective, "About Energy", "Check your Energy");
}
@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

@ -1,5 +1,6 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.finalobj;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -17,7 +18,7 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
{
public DisbandClanGoal(FinalObjective objective)
{
super(objective, "Disband Clan", "Use the /c disband command to delete your Tutorial Clan");
super(objective, "Disband Clan", "Use the /c command to disband your Tutorial Clan");
}
@Override
@ -31,21 +32,16 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
}
@EventHandler(priority = EventPriority.HIGHEST)
public void teleport(ClansCommandPreExecutedEvent event)
public void teleport(ClanDisbandedEvent event)
{
if (event.getArguments().length != 1 || !event.getArguments()[0].equalsIgnoreCase("disband"))
if (!contains(event.getDisbander()))
{
return;
}
if (!contains(event.getPlayer()))
{
return;
}
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have disbanded your Tutorial Clan."));
ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getPlayer()), null);
finish(event.getPlayer());
event.setCancelled(true);
UtilPlayer.message(event.getDisbander(), F.main("Clans", "You have disbanded your Tutorial Clan."));
ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getDisbander()), null);
finish(event.getDisbander());
}
}

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)
{