loaaads of stuff

This commit is contained in:
NewGarbo 2015-11-27 19:42:15 +00:00
parent 0c463cf7cd
commit fe085c1571
17 changed files with 706 additions and 60 deletions

View File

@ -16,6 +16,7 @@ public enum UpdateType
MIN_02(120000),
MIN_01(60000),
SLOWEST(32000),
SEC_30(30000),
SLOWER(16000),
SEC_08(8000),
SLOW(4000),

View File

@ -0,0 +1,9 @@
package mineplex.game.clans.clans;
public enum BedStatus
{
EXISTS_AND_UNOBSTRUCTED,
EXISTS_AND_OBSTRUCTED,
DESTROYED,
DOESNT_EXIST;
}

View File

@ -18,12 +18,14 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.core.war.ClanWarData;
import net.minecraft.server.v1_8_R3.Material;
import mineplex.game.clans.core.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
@ -73,6 +75,8 @@ public class ClanInfo
public ClansManager Clans;
private BedStatus _bedStatus = null;
public ClanInfo(ClansManager clans, ClanToken token)
{
Clans = clans;
@ -90,6 +94,29 @@ public class ClanInfo
}
if (_home != null)
{
if (UtilBlock.isValidBed(_home))
{
if (_home.clone().add(0, 1,0).getBlock().getType().equals(Material.AIR))
{
_bedStatus = BedStatus.EXISTS_AND_UNOBSTRUCTED;
}
else
{
_bedStatus = BedStatus.EXISTS_AND_OBSTRUCTED;
}
}
else
{
_bedStatus = BedStatus.DESTROYED;
}
}
else
{
_bedStatus = BedStatus.DOESNT_EXIST;
}
try
{
if (token.Generator != null && token.Generator.length() > 0)
@ -168,6 +195,16 @@ public class ClanInfo
return Math.max(2, 9 - _memberMap.size());
}
public BedStatus getBedStatus()
{
return _bedStatus;
}
public void setBedStatus(BedStatus bedStatus)
{
_bedStatus = bedStatus;
}
public boolean isRequested(String clan)
{
if (!getRequestMap().containsKey(clan))

View File

@ -17,6 +17,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.event.ClanSetHomeEvent;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
import mineplex.game.clans.core.war.ClanWarData;
@ -593,6 +594,15 @@ public class ClansDataAccessLayer
public void setHome(final ClanInfo clan, Location loc, String player)
{
// Event
ClanSetHomeEvent event = new ClanSetHomeEvent(clan, Bukkit.getPlayer(player), loc);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
// Memory
clan.setHome(loc);

View File

@ -41,6 +41,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
@ -61,6 +62,8 @@ import mineplex.core.projectile.ProjectileManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.commands.ClanManagementCommand;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
@ -969,7 +972,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
@EventHandler
public void hunger(FoodLevelChangeEvent event)
{
if (_clanUtility.getClaim(event.getEntity().getLocation())!=null && _clanUtility.getClaim(event.getEntity().getLocation()).isSafe(event.getEntity().getLocation()))
if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel() && _clanUtility.getClaim(event.getEntity().getLocation())!=null && _clanUtility.getClaim(event.getEntity().getLocation()).isSafe(event.getEntity().getLocation()))
{
event.setCancelled(true);
}
@ -995,6 +998,41 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
@EventHandler
public void updateBedStatus(UpdateEvent event)
{
if (event.getType() != UpdateType.TWOSEC)
{
for (String name : getClanNameSet())
{
ClanInfo clan = _clanUtility.getClanByClanName(name);
if (clan.getHome() != null)
{
if (UtilBlock.isValidBed(clan.getHome()))
{
if (clan.getHome().clone().add(0, 1,0).getBlock().getType().equals(Material.AIR))
{
clan.setBedStatus(BedStatus.EXISTS_AND_UNOBSTRUCTED);
}
else
{
clan.setBedStatus(BedStatus.EXISTS_AND_OBSTRUCTED);
}
}
else
{
clan.setBedStatus(BedStatus.DESTROYED);
}
}
else
{
clan.setBedStatus(BedStatus.DOESNT_EXIST);
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void handleClansDeath(PlayerDeathEvent event)
{

View File

@ -0,0 +1,56 @@
package mineplex.game.clans.clans.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class ClanJoinEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private ClanInfo _clan;
private boolean _cancelled;
public ClanJoinEvent(ClanInfo clan, Player player)
{
_player = player;
_clan = clan;
}
public Player getPlayer()
{
return _player;
}
public ClanInfo getClan()
{
return _clan;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,63 @@
package mineplex.game.clans.clans.event;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class ClanSetHomeEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private ClanInfo _clan;
private Location _loc;
private boolean _cancelled;
public ClanSetHomeEvent(ClanInfo clan, Player player, Location location)
{
_player = player;
_loc = location;
_clan = clan;
}
public Player getPlayer()
{
return _player;
}
public Location getLocation()
{
return _loc;
}
public ClanInfo getClan()
{
return _clan;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,99 @@
package mineplex.game.clans.clans.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.shop.ShopItemButton;
public class ClansPlayerSellItemEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private ShopPageBase<?, ?> _page;
private int _cost;
private int _amount;
private ItemStack _item;
private ShopItemButton<? extends ShopPageBase<?, ?>> _button;
private boolean _cancelled;
public ClansPlayerSellItemEvent(Player player, ShopPageBase<?, ?> page, ShopItemButton<? extends ShopPageBase<?, ?>> shopItemButton, ItemStack item, int cost, int amount)
{
_page = page;
_button = shopItemButton;
_amount = amount;
_item = item;
_player = player;
_cost = cost;
}
public Player getPlayer()
{
return _player;
}
public ShopPageBase<?, ?> getPage()
{
return _page;
}
public ItemStack getItem()
{
return _item;
}
public void setItem(ItemStack item)
{
_item = item;
}
public int getCost()
{
return _cost;
}
public void setCost(int cost)
{
_cost = cost;
}
public int getAmount()
{
return _amount;
}
public void setAmount(int amount)
{
_amount = amount;
}
public ShopItemButton<? extends ShopPageBase<?, ?>> getButton()
{
return _button;
}
public boolean isCancelled()
{
return _cancelled;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -17,6 +17,7 @@ import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementClan;
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementPlayer;
import mineplex.game.clans.clans.scoreboard.elements.ScoreboardElementPlayerCount;
import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.tutorials.Tutorial;
@ -49,6 +50,7 @@ public class ClansScoreboardManager extends ScoreboardManager
data.writeEmpty();
data.writeElement(new ScoreboardElementClan(_clansManager));
data.writeElement(new ScoreboardElementPlayer(_clansManager));
data.writeElement(new ScoreboardElementPlayerCount(_clansManager));
data.writeElement(_worldEvent);
data.writeElement(_warManager);

View File

@ -0,0 +1,35 @@
package mineplex.game.clans.clans.scoreboard.elements;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.game.clans.core.repository.ClanTerritory;
public class ScoreboardElementPlayerCount implements ScoreboardElement
{
private ClansManager _clansManager;
public ScoreboardElementPlayerCount(ClansManager clansManager)
{
_clansManager = clansManager;
}
@Override
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
{
List<String> output = new ArrayList<String>();
output.add(C.cYellow + "Players Online: " + UtilServer.getPlayers().length + "/100");
output.add("");
return output;
}
}

View File

@ -66,7 +66,7 @@ public enum ClansShopItem
SMOOTH_BRICK(100, 20, Material.SMOOTH_BRICK, 1),
CRACKED_STONE_BRICK(25, 5, Material.SMOOTH_BRICK, 1, (byte) 2),
COBBLESTONE(100, 20, Material.COBBLESTONE, 1),
LOG(50, 10, Material.SMOOTH_BRICK, 1),
LOG(50, 10, Material.LOG, 1),
LOG_2(50, 10, Material.LOG_2, 1),
SAND(20, 4, Material.SAND, 1),
GLASS(30, 6, Material.GLASS, 1),

View File

@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
import mineplex.game.clans.economy.GoldManager;
public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
@ -52,6 +53,14 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
return;
}
ClansPlayerSellItemEvent event = new ClansPlayerSellItemEvent(player, _page, ShopItemButton.this, _item, getAmount(player, _item) * _sellPrice, getAmount(player, _item));
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
if (shiftClick)
{
amount = InventoryUtil.getCountOfObjectsRemoved((CraftInventory) player.getInventory(), 36, _item);
@ -62,6 +71,7 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
}
int reward = amount * _sellPrice;
GoldManager.getInstance().addGold(player, reward);
GoldManager.notify(player, String.format("You sold %d items for %dg", amount, reward));
_page.playAcceptSound(player);
@ -124,6 +134,25 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
return InventoryUtil.first((CraftInventory) player.getInventory(), 36, item, true) != -1;
}
private int getAmount(Player player, ItemStack item)
{
int amount = 0;
for (ItemStack stack : player.getInventory().getContents())
{
if (stack == null)
{
continue;
}
if (stack.equals(item))
{
amount++;
}
}
return amount;
}
private void notify(Player player, String message)
{
UtilPlayer.message(player, F.main("Shop", message));

View File

@ -19,6 +19,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
@ -30,6 +32,8 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
@ -42,6 +46,10 @@ import mineplex.game.clans.economy.GoldManager;
*/
public abstract class Tutorial implements ScoreboardElement, Listener
{
public static String TASK_COMPLETE_TASK = "Tutorial%sDoneTask%s";
public static String TUTORIAL_COMPLETE_TASK = "Tutorial%sFinito";
public static String SKIPPED_TASK = "Tutorial%sSkipito";
protected final TutorialManager _manager;
protected final GoldManager _goldManager;
protected final ClansManager _clansManager;
@ -112,7 +120,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
lines.add(" ");
lines.add(C.cYellow + "To skip, type: /skiptutorial");
lines.add(C.cYellow + "To get info, type: /taskinfo");
// lines.add(C.cYellow + "To get info, type: /taskinfo");
return lines;
}
@ -147,7 +155,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_inTutorial.get(player.getName()).setTaskFinished(taskID);
if (!_taskManager.hasCompletedTask(player, _uniqueId + task.getUniqueId()))
if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _uniqueId, task.getUniqueId())))
{
_taskManager.completedTask(new Callback<Boolean>()
{
@ -172,7 +180,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}, player, _uniqueId + task.getUniqueId());
}, player, String.format(TASK_COMPLETE_TASK, _uniqueId, task.getUniqueId()));
}
}
@ -234,7 +242,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1);
UtilPlayer.message(player, F.main("Tutorials", "You have completed the " + F.elem(_friendlyName + " Tutorial") + "."));
onFinished(player);
if (!_taskManager.hasCompletedTask(player, _uniqueId))
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId)))
{
_taskManager.completedTask(new Callback<Boolean>()
{
@ -287,7 +295,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
}, i * 10);
}
}
}, player, _uniqueId);
}, player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId));
}
}
@ -328,6 +336,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
onBegin(player);
}
//_playerTutorials.remove(player.getName());
public void cancelFor(final Player player)
{
_inTutorial.remove(player.getName());
@ -359,15 +369,43 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public boolean hasCompleted(final Player player)
{
return _taskManager.hasCompletedTask(player, _uniqueId);
return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId));
}
public boolean hasSkipped(final Player player)
{
return _taskManager.hasCompletedTask(player, "SKIPPED" + _uniqueId);
return _taskManager.hasCompletedTask(player, String.format(SKIPPED_TASK, _uniqueId));
}
public void skip(final Player player)
{
new JsonMessage(
F.main(
"Tutorial",
"Are you sure you want to skip the tutorial? We "
))
.extra("strongly")
.color("gold")
.extra(" advise you do complete it. You will be rewarded with armor, weapons and")
.color("gray")
.extra(" 30000 Gold")
.color("yellow")
.extra("!")
.color("gray")
.sendToPlayer(player);
new JsonMessage(
F.main(
"Tutorial",
"Click here to confirm you want to skip the tutorial!"
))
.click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip")
.sendToPlayer(player);
}
public void doSkip(final Player player)
{
_taskManager.completedTask(new Callback<Boolean>()
{
@ -375,7 +413,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{
cancelFor(player);
}
}, player, "SKIPPED" + _uniqueId);
}, player, String.format(SKIPPED_TASK, _uniqueId));
}
public String getUniqueId()
@ -388,6 +426,23 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return _inTutorial.get(player.getName());
}
@EventHandler
public void taskInfo(final UpdateEvent evt)
{
if (evt.getType() != UpdateType.SEC_30)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
if (isInTutorial(player))
{
getTask(get(player).getCurrentTask()).sendDescriptionTo(player);
}
}
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent evt)
{

View File

@ -7,26 +7,24 @@ import mineplex.core.task.TaskManager;
public class TutorialClient
{
private final TaskManager _taskManager;
private final Tutorial _tutorial;
private final Player _player;
private int _currentTask = 1;
public TutorialClient(final Player player, final TaskManager taskManager, final Tutorial tutorial)
public TutorialClient(final Player player, final Tutorial tutorial)
{
_player = player;
_taskManager = taskManager;
_tutorial = tutorial;
}
public static TutorialClient create(final Player player, final TaskManager taskManager, final Tutorial tutorial)
{
final TutorialClient user = new TutorialClient(player, taskManager, tutorial);
final TutorialClient user = new TutorialClient(player, tutorial);
for (final int i : tutorial.getTasks().keySet())
{
if (taskManager.hasCompletedTask(player, tutorial.getUniqueId() + tutorial.getTask(i).getUniqueId()))
if (taskManager.hasCompletedTask(player, String.format(Tutorial.TASK_COMPLETE_TASK, tutorial.getUniqueId(), tutorial.getTask(i).getUniqueId())))
{
user._currentTask = i;
}
@ -58,11 +56,6 @@ public class TutorialClient
return _player;
}
public TaskManager getTaskManager()
{
return _taskManager;
}
public void setTaskFinished(final int taskID)
{
_currentTask = taskID + 1;
@ -72,7 +65,7 @@ public class TutorialClient
public boolean hasFinishedTask(final TutorialTask task)
{
return task.getID() < _currentTask;
return task != null && task.getID() < _currentTask;
}
}

View File

@ -20,6 +20,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
import mineplex.game.clans.tutorials.commands.TaskInfoCommand;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
@ -46,8 +47,9 @@ public class TutorialManager extends MiniPlugin
public void addCommands()
{
this.addCommand(new SkipTutorialCommand(this));
this.addCommand(new TaskInfoCommand(this));
addCommand(new SkipTutorialCommand(this));
addCommand(new DoSkipTutorialCommand(this));
addCommand(new TaskInfoCommand(this));
}
public boolean startTutorial(final Class<? extends Tutorial> tutorial, final Player player)
@ -90,10 +92,15 @@ public class TutorialManager extends MiniPlugin
if (isInTutorial(player))
{
getTutorial(player).skip(player);
}
}
public void doSkip(final Player player)
{
if (isInTutorial(player))
{
UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._friendlyName + " Tutorial") + "."));
_playerTutorials.remove(player.getName());
getTutorial(player).doSkip(player);
}
}

View File

@ -0,0 +1,31 @@
package mineplex.game.clans.tutorials.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.tutorials.TutorialManager;
public class DoSkipTutorialCommand extends CommandBase<TutorialManager>
{
public DoSkipTutorialCommand(final TutorialManager plugin)
{
super(plugin, Rank.ALL, "yesiconfirmiwanttoskip");
}
@Override
public void Execute(final Player caller, final String[] args)
{
if (Plugin.isInTutorial(caller))
{
Plugin.doSkip(caller);
}
else
{
UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial."));
}
}
}

View File

@ -1,20 +1,32 @@
package mineplex.game.clans.tutorials.types;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilItem.ItemCategory;
import mineplex.core.donation.DonationManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanSetHomeEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.spawn.Spawn;
@ -32,52 +44,69 @@ public class TutorialGettingStarted extends Tutorial
addTask(1, "Welcome",
"Welcome to Clans! "
+ "To start playing Clans, you need to create a Clan by typing {/c create [Clan Name]}! "
+ "Don't worry though, at the end of this tutorial, you will be deleting this clan.");
+ "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan!"
+ "You can also join a friend's Clan if they invite you to it!"
+ "When you finish the tutorial, you will be awarded {30,000 Gold}");
addTask(2, "Viewing Clan Details",
addTask(2, "Create a clan",
"Before beginning, use the {/c create <ClanName>} command to start up your own Clan!"
+ "Alternatively, you can join a friend's Clan, if they have invited you, instead of making your own.");
addTask(3, "Viewing Clan Details",
"Now you can view information about your Clan. "
+ "To do this type {/c [Clan Name]}! "
+ "You can also use any Clans name to get some information about them as well.");
addTask(3, "Leave Spawn Islands",
addTask(4, "Leave Spawn Islands",
"Now you can leave the Spawn Island. "
+ "Don't worry, you won't get hurt from the fall! "
+ "Once you end the tutorial, PvP will be enabled down there, so be careful!");
addTask(4, "Go To The Wilderness",
addTask(5, "Go To The Wilderness",
"Use your Map (Slot 9) to help find your way to the Wilderness. "
+ "The Wilderness is anywhere that is not colored on the Map. "
+ "If you don't have a map, you can get one at any time by typing {/map}. "
+ "You can zoom in/out by Left and Right Clicking!");
addTask(5, "Claim some Territory",
addTask(6, "Claim some Territory",
"Clans can claim 16x16 areas of Territory! "
+ "Once claimed, only your Clan can break/place blocks here. "
+ "This is the perfect place to build a base and stash your items!"
+ "You can only claim in the Wilderness, and not next to other Clans Territory. "
+ "Claim some Territory now, by typing {/c claim}! ",
"Good job! We won't acutally claim this Territory yet!");
"Good job! We won't actually claim this Territory yet!");
addTask(6, "Explore the Shops",
addTask(7, "Set Clan Home",
"You are now ready to set a Clan Home."
+ "To do this, use the {/c sethome} command.");
addTask(8, "Explore the Shops",
"You can buy all sorts of things at the Shops! "
+ "You can also sell things to the Villagers for Gold! "
+ "Look at your Map and take notice of where the Shops is. "
+ "You can also transfer 1,000 Gems into 30,000 Clans Gold each day.");
+ "You can also transfer {1,000 Gems} into {32,000 Clans Gold} each day.");
addTask(7, "Use a Class Ability",
addTask(9, "Equip a Class",
"Find the PvP Gear shop, and Right-Click the Villager. "
+ "Purchase Armor (all of the same type) and Sword from the PvP Shop. "
+ "Then put on your Armor to equip a Champions Class. "
+ "Purchase Iron Armor from the PvP Shop. (FREE) "
+ "Then put on your Armor to equip a Champions Class. ");
addTask(10, "Use a Class Ability",
"Now that you have Equipped a Class, you can start using Abilities. "
+ "Purchase a Sword from the PvP Shop. (FREE) "
+ "Right-Click with your Sword to use your Sword Ability!");
addTask(8, "Class Customization",
addTask(11, "Class Customization",
"To customize your Class, Right-Click an Enchantment Table! "
+ "There should be one nearby in the Shops!"
+ "Find it, and try customizing your Class! ");
addTask(9, "Disband your Clan",
addTask(12, "Making Money (Farming)",
"We have given you a few Carrots, as a starter for your Farming career. "
+ "Go to the Organic Produce Villager in one of the Shops, and sell the Carrots for {Gold}.");
addTask(13, "Disband your Clan",
"Finally, let's disband your Clan to end the Tutorial. "
+ "Simply type {/c disband} to do this. "
+ "This will delete your Clan, and you'll be able to create or join a new one!");
@ -98,6 +127,110 @@ public class TutorialGettingStarted extends Tutorial
player.resetPlayerTime();
}
@EventHandler
public void button(ClansShopAddButtonEvent event)
{
if (get(event.getPlayer()).hasFinishedTask(getTask("Explore the Shops")) && !get(event.getPlayer()).hasFinishedTask(getTask("Equip a Class")))
{
if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial())))
{
return;
}
if (!_taskManager.hasCompletedTask(event.getPlayer(), "GettingStartedBought" + event.getMaterial().name()))
{
event.setBuyPrice(0);
event.setSellPrice(0);
}
}
}
@EventHandler
public void swordbutton(ClansShopAddButtonEvent event)
{
if (get(event.getPlayer()).hasFinishedTask(getTask("Equip A Class")) && !get(event.getPlayer()).hasFinishedTask(getTask("Use a Class Ability")))
{
if (!(UtilItem.isSword(event.getMaterial())))
{
return;
}
if (!_taskManager.hasCompletedTask(event.getPlayer(), "GettingStartedBoughtSword"))
{
event.setBuyPrice(0);
event.setSellPrice(0);
}
}
}
@EventHandler
public void buy(final ClansPlayerBuyItemEvent event)
{
if (get(event.getPlayer()).hasFinishedTask(getTask("Explore the Shops")) && !get(event.getPlayer()).hasFinishedTask(getTask("Equip a Class")))
{
if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType())))
{
return;
}
_taskManager.completedTask(new Callback<Boolean>(){
@Override
public void run(Boolean data)
{
}
}, event.getPlayer(), "GettingStartedBought" + event.getItem().getType().name());
}
}
@EventHandler
public void buysword(final ClansPlayerBuyItemEvent event)
{
if (get(event.getPlayer()).hasFinishedTask(getTask("Equip A Class")) && !get(event.getPlayer()).hasFinishedTask(getTask("Use a Class Ability")))
{
if (UtilItem.isSword(event.getItem().getType()))
{
_taskManager.completedTask(new Callback<Boolean>() {
@Override
public void run(Boolean data)
{
}
}, event.getPlayer(), "GettingStartedBoughtSword");
}
}
}
@EventHandler
public void sell(ClansPlayerSellItemEvent event)
{
if (get(event.getPlayer()).hasFinishedTask(getTask("Class Customization")) && !get(event.getPlayer()).hasFinishedTask(getTask("Making Money (Farming)")))
{
finishTask(event.getPlayer(), "Making Money (Farming)");
}
}
@Override
public void onBegin(final Player player)
{
UtilPlayer.message(player, F.main("Tutorials", "Welcome to the " + F.elem("Getting Started Tutorial!")));
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() {
public void run()
{
finishTask(player, "Welcome");
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() {
public void run()
{
if (_clansManager.isInClan(player) && _clansManager.getClan(player).getClansPlayerFromName(player.getName()).getRole().has(ClanRole.ADMIN))
{
finishTask(player, "Create a clan");
}
}
}, 20L);
}
}, 80L);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onClanCreated(ClanCreatedEvent event)
{
@ -106,9 +239,23 @@ public class TutorialGettingStarted extends Tutorial
return;
}
if (isInTutorial(event.getFounder()) && !get(event.getFounder()).hasFinishedTask(getTask("Welcome")))
if (isInTutorial(event.getFounder()) && get(event.getFounder()).hasFinishedTask(getTask("Welcome")) && !get(event.getFounder()).hasFinishedTask(getTask("Create a clan")))
{
finishTask(event.getFounder(), "Welcome");
finishTask(event.getFounder(), "Create a clan");
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onClanJoined(ClanJoinEvent event)
{
if (event.getPlayer() == null)
{
return;
}
if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Welcome")) && !get(event.getPlayer()).hasFinishedTask(getTask("Create a clan")))
{
finishTask(event.getPlayer(), "Create a clan");
}
}
@ -132,39 +279,48 @@ public class TutorialGettingStarted extends Tutorial
{
if (event.getCommand().equals("info"))
{
if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Welcome")) && !get(event.getPlayer()).hasFinishedTask(getTask("Viewing Clan Info")))
if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Create a clan")) && !get(event.getPlayer()).hasFinishedTask(getTask("Viewing Clan Details")))
{
finishTask(event.getPlayer(), "Viewing Clan Info");
finishTask(event.getPlayer(), "Viewing Clan Details");
}
}
else if (event.getCommand().equals("claim"))
{
if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Go To The Wilderness")) && !get(event.getPlayer()).hasFinishedTask(getTask("Claiming Territory")))
{
finishTask(event.getPlayer(), "Claiming Territory");
finishTask(event.getPlayer(), "Claim some Territory");
event.getPlayer().teleport(Spawn.getNorthTown());
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSethome(ClanSetHomeEvent event)
{
if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Claim some Territory")) && !get(event.getPlayer()).hasFinishedTask(getTask("Set Clan Home")))
{
finishTask(event.getPlayer(), "Set Clan Home");
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onTerritory(final PlayerEnterTerritoryEvent event)
{
final Player player = event.getPlayer();
final String newTerritory = event.getNewTerritory();
if (isInTutorial(player) && newTerritory.contains("Spawn") && get(player).hasFinishedTask(getTask("Viewing Clan Info")) && !get(player).hasFinishedTask(getTask("Leave Spawn")))
if (isInTutorial(player) && newTerritory.contains("Spawn") && get(player).hasFinishedTask(getTask("Viewing Clan Details")) && !get(player).hasFinishedTask(getTask("Leave Spawn Islands")))
{
finishTask(player, "Leave Spawn");
finishTask(player, "Leave Spawn Islands");
}
else if (isInTutorial(player) && newTerritory.contains("Wilderness") && get(player).hasFinishedTask(getTask("Leave Spawn")) && !get(player).hasFinishedTask(getTask("Go To The Wilderness")))
else if (isInTutorial(player) && newTerritory.contains("Wilderness") && get(player).hasFinishedTask(getTask("Leave Spawn Islands")) && !get(player).hasFinishedTask(getTask("Go To The Wilderness")))
{
finishTask(player, "Go To The Wilderness");
}
else if (isInTutorial(player) && newTerritory.contains("Shops") && get(player).hasFinishedTask(getTask("Claiming Territory")) && !get(player).hasFinishedTask(getTask("Visit The Shops")))
else if (isInTutorial(player) && newTerritory.contains("Shops") && get(player).hasFinishedTask(getTask("Claim some Territory")) && !get(player).hasFinishedTask(getTask("Explore the Shops")))
{
finishTask(player, "Visit The Shops");
finishTask(player, "Explore the Shops");
}
}
@ -173,9 +329,38 @@ public class TutorialGettingStarted extends Tutorial
{
final Player player = event.GetPlayer();
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Visit The Shops")) && !get(player).hasFinishedTask(getTask("Use An Ability")))
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Equip a Class")) && !get(player).hasFinishedTask(getTask("Use a Class Ability")))
{
finishTask(player, "Use An Ability");
finishTask(player, "Use a Class Ability");
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onUpdated(final UpdateEvent event)
{
for (Player player : UtilServer.getPlayers())
{
if (!isInTutorial(player))
{
continue;
}
ClientClass client = _clansManager.getClassManager().Get(player);
if (client == null)
{
continue;
}
if (client.GetGameClass() == null)
{
return;
}
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Explore the Shops")) && !get(player).hasFinishedTask(getTask("Equip a Class")))
{
finishTask(player, "Use a Class Ability");
}
}
}
@ -193,13 +378,14 @@ public class TutorialGettingStarted extends Tutorial
{
client.getPlayer().setPlayerTime(6000, false);
if (get(client.getPlayer()).hasFinishedTask(getTask("Use An Ability")) && !get(client.getPlayer()).hasFinishedTask(getTask("Class Customization")))
if (get(client.getPlayer()).hasFinishedTask(getTask("Equip a Class")) && !get(client.getPlayer()).hasFinishedTask(getTask("Class Customization")))
{
final ClientClass clientclass = _clansManager.getClassManager().Get(client.getPlayer());
if (clientclass != null && clientclass.GetSavingCustomBuild() != null)
{
finishTask(client.getPlayer(), "Class Customization");
client.getPlayer().getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 5));
}
}
}
@ -209,15 +395,10 @@ public class TutorialGettingStarted extends Tutorial
@EventHandler(priority = EventPriority.MONITOR)
public void onDeletedClan(final ClanDisbandedEvent event)
{
if (isInTutorial(event.getDisbander()) && get(event.getDisbander()).hasFinishedTask(getTask("Class Customization")) && !get(event.getDisbander()).hasFinishedTask(getTask("Disband Clan")))
if (isInTutorial(event.getDisbander()) && get(event.getDisbander()).hasFinishedTask(getTask("Making Money (Farming)")) && !get(event.getDisbander()).hasFinishedTask(getTask("Disband your Clan")))
{
finishTask(event.getDisbander(), "Disband Clan");
finishTask(event.getDisbander(), "Disband your Clan");
}
}
public void onBegin(final Player player)
{
UtilPlayer.message(player, F.main("Tutorials", "Welcome to the " + F.elem("Getting Started Tutorial!")));
}
}