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

This commit is contained in:
phobia 2016-03-31 20:35:40 +11:00
commit 19b2b00a13
28 changed files with 213 additions and 39 deletions

View File

@ -6,12 +6,15 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.game.clans.tutorial.TutorialRegion;
/**
@ -24,6 +27,10 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
private String _name;
private String _description;
private String _extraDescription;
private boolean _displayStartMessage;
private int _startMessageDelay;
private boolean _displayFinishMessage;
private int _finishMessageDelay;
private HashMap<UUID, Data> _active;
private List<ObjectiveListener> _listeners;
@ -35,6 +42,10 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
_name = name;
_description = description;
_extraDescription = extraDescription;
_displayStartMessage = true;
_displayFinishMessage = true;
_startMessageDelay = 60;
_finishMessageDelay = 1;
_active = new HashMap<>();
_listeners = new LinkedList<>();
@ -114,6 +125,9 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
_listeners.forEach(listener -> listener.onObjectiveStart(player, this));
if (_displayStartMessage)
Bukkit.getServer().getScheduler().runTaskLater(getJavaPlugin(), () -> showStartMessage(player), _startMessageDelay);
customStart(player);
}
@ -181,8 +195,13 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
{
System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName(player)));
showFinishMessage(player);
_active.remove(player.getUniqueId());
if (_displayFinishMessage)
Bukkit.getServer().getScheduler().runTaskLater(getJavaPlugin(), () -> showFinishMessage(player), _finishMessageDelay);
customFinish(player);
_listeners.forEach(listener -> listener.onObjectiveFinish(player, this));
@ -241,4 +260,44 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
}
public abstract void addScoreboardLines(Player player, List<String> lines);
private void showStartMessage(Player player)
{
UtilTextMiddle.display(C.cAqua + "Tutorial", getName(player), player);
}
private void showFinishMessage(Player player)
{
UtilTextMiddle.display(C.cGreen + "Tutorial Completed", getName(player), player);
}
public void setDisplayStartMessage(boolean displayStartMessage)
{
_displayStartMessage = displayStartMessage;
}
public void setDisplayFinishMessage(boolean displayFinishMessage)
{
_displayFinishMessage = displayFinishMessage;
}
public int getStartMessageDelay()
{
return _startMessageDelay;
}
public void setStartMessageDelay(int startMessageDelay)
{
_startMessageDelay = startMessageDelay;
}
public int getFinishMessageDelay()
{
return _finishMessageDelay;
}
public void setFinishMessageDelay(int finishMessageDelay)
{
_finishMessageDelay = finishMessageDelay;
}
}

View File

@ -4,9 +4,12 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.game.clans.tutorial.TutorialRegion;
public abstract class ObjectiveGoal <T extends Objective> implements Listener
@ -17,6 +20,10 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
private String _name;
private String _description;
private String _extraDescription;
private boolean _displayStartMessage;
private int _startMessageDelay;
private boolean _displayFinishMessage;
private int _finishMessageDelay;
public ObjectiveGoal(T objective, String name, String description)
{
@ -31,6 +38,10 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
_name = name;
_description = description;
_extraDescription = extraDescription;
_displayStartMessage = true;
_startMessageDelay = 40;
_displayFinishMessage = true;
_finishMessageDelay = 1;
}
public String getName(Player player)
@ -68,6 +79,12 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
System.out.println(String.format("Tutorial> [%s] started objective goal [%s]", player.getName(), getName(player)));
_active.add(player.getUniqueId());
if (_displayStartMessage)
{
Bukkit.getServer().getScheduler().runTaskLater(_objective.getJavaPlugin(), () -> displayStartMessage(player), _startMessageDelay);
}
customStart(player);
}
@ -96,10 +113,15 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
System.out.println(String.format("Tutorial> [%s] finished objective goal [%s]", player.getName(), getName(player)));
_active.remove(player.getUniqueId());
if (_displayFinishMessage)
{
Bukkit.getServer().getScheduler().runTaskLater(_objective.getJavaPlugin(), () -> displayFinishMessage(player), _finishMessageDelay);
}
customFinish(player);
_objective.completeGoal(this, player);
}
}
@ -123,4 +145,34 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
{
return _objective;
}
protected void displayFinishMessage(Player player)
{
UtilTextMiddle.display(C.cGreen + "Completed Objective", getName(player), player);
}
protected void displayStartMessage(Player player)
{
UtilTextMiddle.display(C.cYellow + "New Objective", getName(player), player);
}
public void setDisplayStartMessage(boolean displayStartMessage)
{
_displayStartMessage = displayStartMessage;
}
public void setDisplayFinishMessage(boolean displayFinishMessage)
{
_displayFinishMessage = displayFinishMessage;
}
public void setStartMessageDelay(int startMessageDelay)
{
_startMessageDelay = startMessageDelay;
}
public void setFinishMessageDelay(int finishMessageDelay)
{
_finishMessageDelay = finishMessageDelay;
}
}

View File

@ -20,6 +20,8 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv;
@ -28,6 +30,7 @@ import mineplex.core.hologram.HologramManager;
import mineplex.core.npc.NpcManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.economy.GoldManager;
@ -128,6 +131,27 @@ public class ClansMainTutorial extends Tutorial
player.getInventory().clear();
ClansManager.getInstance().getPvpTimer().pause(player);
// Spawn Holograms
addHologram(player,
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!");
addHologram(player,
getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -23),
"Jump Off!");
ClanInfo clan = ClansManager.getInstance().getClan(player);
if (clan != null)
{
ClansManager.getInstance().getClanDataAccess().delete(clan, null);
}
}
@Override

View File

@ -13,6 +13,7 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.LoadCannonGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.MountCannonGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanInfoGoal;
import java.util.HashMap;
import java.util.Map;
@ -24,15 +25,18 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Attack Enemy", "Attack and raid this enemy!");
super(clansMainTutorial, javaPlugin, "Enemy Clans", "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"));
addGoal(new HoldItemGoal(this, Material.MAP, "Identify Enemy on Map", "By looking at your map, identify your new enemy", 40));
addGoal(new ClanInfoGoal(this));
addGoal(new MountCannonGoal(this));
addGoal(new LoadCannonGoal(this));
addGoal(new BlowUpWallGoal(this));
addGoal(new StealEnemyPotatoesGoal(this));
setStartMessageDelay(60);
}
@Override

View File

@ -13,16 +13,17 @@ public class ClanObjective extends OrderedObjective<ClansMainTutorial>
{
public ClanObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Clans", "Create clan with /c create <name>");
super(clansMainTutorial, javaPlugin, "Clan Basics", "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));
// Wait 1 second because the player is logging in/loading
setStartMessageDelay(20);
}
@Override

View File

@ -18,6 +18,8 @@ public class ClassesObjective extends OrderedObjective<ClansMainTutorial>
addGoal(new EquipDefaultBuildGoal(this));
addGoal(new OpenClassManagerGoal(this));
addGoal(new UseBullsChargeGoal(this));
setStartMessageDelay(60);
}
@Override

View File

@ -16,6 +16,8 @@ public class EnergyObjective extends OrderedObjective<ClansMainTutorial>
addGoal(new ExplainEnergyGoal(this));
addGoal(new BuyEnergyGoal(this));
setStartMessageDelay(60);
}
@Override

View File

@ -18,10 +18,12 @@ public class FieldsObjective extends OrderedObjective<ClansMainTutorial>
{
super(clansMainTutorial, javaPlugin, "Fields", "Get various resources by mining for them in the fields");
addGoal(new HoldItemGoal(this, Material.MAP, "Identify Fields", "Look at your map and find the Fields Region"));
addGoal(new HoldItemGoal(this, Material.MAP, "Identify Fields on Map", "Look at your map and find the Fields Region"));
addGoal(new GoToFieldsGoal(this));
addGoal(new MineDiamondsGoal(this));
addGoal(new SellDiamondsGoal(this));
setStartMessageDelay(60);
}
@Override

View File

@ -16,6 +16,8 @@ public class FinalObjective extends OrderedObjective<ClansMainTutorial>
addGoal(new TpClanHomeGoal(this)); // IMPLEMENTED
addGoal(new DisbandClanGoal(this)); // IMPLEMENTED
setStartMessageDelay(60);
}
@Override

View File

@ -20,6 +20,8 @@ public class PurchaseItemsObjective extends UnorderedObjective<ClansMainTutorial
addGoal(new PurchaseGoal(this, Material.IRON_BOOTS, "Purchase Iron Boots", "Talk to the Pvp Gear NPC and purchase Iron Boots"));
addGoal(new PurchaseGoal(this, Material.IRON_AXE, "Purchase Iron Axe", "Talk to the Pvp Gear NPC and purchase an Iron Axe"));
// addGoal(new PurchaseGoal(this, Material.IRON_PICKAXE, "Purchase Iron Pickaxe", "Talk to the Pvp Gear NPC and purchase an Iron Pickaxe"));
setStartMessageDelay(60);
}
@Override

View File

@ -35,9 +35,11 @@ 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 HoldItemGoal(this, Material.MAP, "Identify Shops on Map", "Look at your map and find the shops"));
addGoal(new GoToShopsGoal(this));
addGoal(new SellPotatoesGoal(this));
setStartMessageDelay(60);
}
@Override

View File

@ -17,11 +17,18 @@ public class HoldItemGoal extends ObjectiveGoal<Objective>
private DefaultHashMap<String, EnclosedObject<Integer>> _ticksHeld = new DefaultHashMap<>(key -> new EnclosedObject<>(Integer.valueOf(0)));
private Material _material;
public HoldItemGoal(Objective objective, Material material, String name, String description)
public HoldItemGoal(Objective objective, Material material, String name, String description, int startDelay)
{
super(objective, name, description);
_material = material;
setStartMessageDelay(startDelay);
}
public HoldItemGoal(Objective objective, Material material, String name, String description)
{
this(objective, material, name, description, 120);
}
@Override

View File

@ -24,7 +24,7 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
{
public BlowUpWallGoal(AttackEnemyObjective objective)
{
super(objective, "Attack Enemy", "Attack enemy clan! Blow a hole in their base by Left-Clicking to fire the Cannon.");
super(objective, "Blow up the Enemy Base", "Attack enemy clan! Blow a hole in their base by Left-Clicking to fire the Cannon.");
}
@Override

View File

@ -16,6 +16,8 @@ public class GetMapGoal extends ObjectiveGoal<AttackEnemyObjective>
public GetMapGoal(AttackEnemyObjective objective)
{
super(objective, "Get a Map", "Use the /map command to recieve a map.");
setStartMessageDelay(120);
}
@Override

View File

@ -13,7 +13,7 @@ public class LoadCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
{
public LoadCannonGoal(AttackEnemyObjective objective)
{
super(objective, "Load Cannon", "Right click to open the Cannon, and load it with TNT!");
super(objective, "Load the Cannon", "Right click to open the Cannon, and load it with TNT!");
}
@Override

View File

@ -20,7 +20,7 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
{
public MountCannonGoal(AttackEnemyObjective objective)
{
super(objective, "Get on Cannon", "Right click on the Cannon to hop on!");
super(objective, "Get on the Cannon", "Right click on the Cannon to hop on!");
}
@Override

View File

@ -27,7 +27,7 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal<AttackEnemyObjective>
public StealEnemyPotatoesGoal(AttackEnemyObjective objective)
{
super(objective, "Steal Enemy Potatoes", "Steal the enemy's potatoes");
super(objective, "Steal Potatoes", "Steal the enemy's potatoes");
}
@Override

View File

@ -35,7 +35,7 @@ public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
public BuildHouseGoal(ClanObjective objective)
{
super(objective, "Build House", "Build a Stone Brick house. (Place all your blocks)");
super(objective, "Build a House", "Build a Stone Brick house. (Place all your blocks)");
}
@Override

View File

@ -1,8 +1,6 @@
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;
@ -12,7 +10,7 @@ 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 mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -20,17 +18,16 @@ import java.sql.Timestamp;
import java.util.UUID;
public class ClanInfoGoal extends ObjectiveGoal<ClanObjective>
public class ClanInfoGoal extends ObjectiveGoal<AttackEnemyObjective>
{
public ClanInfoGoal(ClanObjective objective)
public ClanInfoGoal(AttackEnemyObjective objective)
{
super(objective, "Info on other clan", "Get info on other clans by using the command /c <ClanName>");
super(objective, "Lookup Enemy Details", "View info about the enemy clan by typing /c EnemyClan");
}
@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
@ -46,23 +43,27 @@ public class ClanInfoGoal extends ObjectiveGoal<ClanObjective>
if(event.getArguments().length < 1) return;
event.setCancelled(true);
event.setCancelled(true);
if (!event.getArguments()[0].equalsIgnoreCase("EnemyClan"))
{
// Display info
return;
}
ClanToken token = new ClanToken();
token.Name = event.getArguments()[0];
token.Description = "Best clan ever!";
token.Name = "EnemyClan";
token.Description = "The meanest clan in the world!";
token.Home = "";
token.Admin = false;
token.Energy = 4320;
token.Id = UtilMath.random.nextInt(100);
token.Energy = UtilMath.random.nextInt(1000);
token.Id = -1;
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());
token.DateCreated = new Timestamp(System.currentTimeMillis() - (UtilTime.TimeUnit.DAYS.getMilliseconds() * 10));
token.LastOnline = new Timestamp(System.currentTimeMillis() - (UtilTime.TimeUnit.DAYS.getMilliseconds() * 1));
ClanInfo clan = new ClanInfo(ClansManager.getInstance(), token);

View File

@ -19,7 +19,7 @@ public class ClanManagementGoal extends ObjectiveGoal<ClanObjective>
{
public ClanManagementGoal(ClanObjective objective)
{
super(objective, "Manage your clan", "Manage your clan by using the command /c");
super(objective, "Open the Clan Menu", "Manage your clan by using the command /c");
}
@Override

View File

@ -19,20 +19,15 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
public LeaveSpawnGoal(ClanObjective objective)
{
super(objective, "Leave Spawn", "Exit the tutorial spawn area");
// 2 seconds after start message
setStartMessageDelay(20 * 3);
}
@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

View File

@ -18,7 +18,9 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
{
public SetHomeGoal(ClanObjective objective)
{
super(objective, "Set Home", "Set your Clan's home by typing /c sethome");
super(objective, "Set Clan Home", "Set your Clan's home by typing /c sethome");
setDisplayFinishMessage(false);
}
@Override

View File

@ -12,6 +12,8 @@ public class EquipDefaultBuildGoal extends ObjectiveGoal<ClassesObjective>
public EquipDefaultBuildGoal(ClassesObjective objective)
{
super(objective, "Equip Armor", "Equip your newly bought armor to try out it's abilities");
setStartMessageDelay(120);
}
@Override

View File

@ -37,6 +37,8 @@ public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
finish(player);
}, 20 * 10L);
}, 20 * 3L);
setStartMessageDelay(120);
}
@Override

View File

@ -29,6 +29,8 @@ public class SellDiamondsGoal extends ObjectiveGoal<FieldsObjective>
{
// Close Middle Gate
getObjective().getPlugin().destroyFences(getObjective().getPlugin().getRegion(player), DyeColor.RED);
// Close Fields Gate
getObjective().getPlugin().destroyFences(getObjective().getPlugin().getRegion(player), DyeColor.BLACK);
}
@EventHandler

View File

@ -21,6 +21,8 @@ public class TpClanHomeGoal extends ObjectiveGoal<FinalObjective>
public TpClanHomeGoal(FinalObjective objective)
{
super(objective, "Teleport to Clan Home", "Use the /c home command to teleport to your Clan Home");
setStartMessageDelay(120);
}
@Override

View File

@ -17,6 +17,9 @@ public class PurchaseGoal extends ObjectiveGoal
{
super(objective, name, description);
_material = material;
setDisplayStartMessage(false);
setDisplayFinishMessage(false);
}
@Override

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
@ -29,6 +30,9 @@ public class SellPotatoesGoal extends ObjectiveGoal<ShopsObjective>
{
// Shops Fences Closed
getObjective().getPlugin().spawnFences(getObjective().getPlugin().getRegion(player), DyeColor.BROWN);
// Remove all potatoes from inventory
UtilInv.removeAll(player, Material.POTATO_ITEM, (byte) 0);
}
@EventHandler