Finishing touches with UtilItem. Lots of changes to tutorials, and added a PlayerEnterTerritory event.

This commit is contained in:
NewGarbo 2015-10-29 08:35:24 +00:00
parent a063da4cae
commit d0bfb2e2e9
12 changed files with 801 additions and 516 deletions

View File

@ -16,7 +16,6 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
import mineplex.game.clans.clans.war.ClanWar;
import mineplex.game.clans.clans.war.WarManager;
@ -613,9 +612,6 @@ public class ClansDataAccessLayer
}
});
//Tutorial
((TutorialGettingStarted) _tutorialManager.getTutorials().get(TutorialType.GETTING_STARTED)).onHomeSet(player);
//Log
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
}

View File

@ -19,11 +19,8 @@ import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
import mineplex.game.clans.tutorials.types.TutorialOnGoingMap;
public class ClansDisplay extends MiniPlugin
{
@ -62,12 +59,17 @@ public class ClansDisplay extends MiniPlugin
if (client.isAutoClaim()) Clans.getClanAdmin().claim(player);
// Map
String owner = "?";
String owner = "Wilderness";
ClanInfo ownerClan = Clans.getClanUtility().getOwner(player.getLocation());
if (ownerClan != null) owner = ownerClan.getName();
boolean safe = Clans.getClanUtility().isSafe(player);
if (!client.getOwner().equals(owner))
{
UtilServer.getServer().getPluginManager().callEvent(new PlayerEnterTerritoryEvent(player, client.getOwner(), owner));
}
if (!client.isMapOn())
{
boolean showChange = false;
@ -86,7 +88,11 @@ public class ClansDisplay extends MiniPlugin
showChange = true;
}
if (showChange) displayOwner(player);
if (showChange)
{
displayOwner(player);
// Event
}
}
else
{
@ -115,8 +121,6 @@ public class ClansDisplay extends MiniPlugin
UtilTextMiddle.display("", ownerString, 0, 25, 10, player);
UtilPlayer.message(player, F.main("Territory", ownerString));
((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onEnterTerritory(player, ownerString);
((TutorialOnGoingMap) TutorialManager.Instance.getTutorials().get(TutorialType.ON_GOING)).onEnterTerritory(player, ownerString);
}
public int width = 8;

View File

@ -317,6 +317,10 @@ public class ClansCommand extends CommandBase<ClansManager>
{
// Inform
UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " disbanded " + F.elem("Clan " + clan.getName()) + "."));
if (TutorialManager.Instance.isInTutorial(caller) && TutorialManager.Instance.getTutorial(caller) instanceof TutorialGettingStarted){
((TutorialGettingStarted) TutorialManager.Instance.getTutorial(caller)).onDeletedClan(caller);
}
}
else
{

View File

@ -0,0 +1,47 @@
package mineplex.game.clans.clans.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerEnterTerritoryEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private String _newTerritory;
private String _lastTerritory;
private Player _player;
public PlayerEnterTerritoryEvent(Player player, String lastTerritory, String newTerritory)
{
_player = player;
_lastTerritory = lastTerritory;
_newTerritory = newTerritory;
}
public Player getPlayer()
{
return _player;
}
public String getLastTerritory()
{
return _lastTerritory;
}
public String getNewTerritory()
{
return _newTerritory;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -128,8 +128,6 @@ public class MurderManager extends MiniClientPlugin<ClientMurder>
{
for (Player other : UtilServer.getPlayers())
{
System.out.println(inventoryValue);
if (canMurderOccur(other, player, other.getLocation()) && inventoryValue <= 2000)
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.ANGRY_VILLAGER, player.getEyeLocation().add(0, 0.25, 0), 0, 0, 0, 0, 1, UtilParticle.ViewDist.NORMAL, other);

View File

@ -2,6 +2,7 @@ package mineplex.game.clans.shop;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
@ -9,6 +10,8 @@ import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.Clans;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
public abstract class ClansShopPage<T extends ShopBase<ClansManager>> extends ShopPageBase<ClansManager, T>
{
@ -61,6 +64,15 @@ public abstract class ClansShopPage<T extends ShopBase<ClansManager>> extends Sh
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data, String displayName, int amount)
{
if (TutorialManager.Instance.isInTutorial(getPlayer()) && TutorialManager.Instance.getTutorial(getPlayer()) instanceof TutorialGettingStarted)
{
if (((TutorialGettingStarted) TutorialManager.Instance.getTutorial(getPlayer())).nullPrices(new ItemStack(material, amount), getPlayer()))
{
buyPrice = 0;
sellPrice = 0;
}
}
PvpItem item = new PvpItem(material, data, 1, displayName, buyPrice, sellPrice, 64);
addButton(slot, item, new ShopItemButton<ClansShopPage<?>>(this, buyPrice, sellPrice, material, data, amount));
}

View File

@ -7,17 +7,21 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager;
@ -42,10 +46,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
private final HashMap<Integer, TutorialTask> _tasks;
private final HashMap<String, TutorialTask> _nameToTask;
protected final HashMap<String, PlayerTutorial> _inTutorial;
protected final HashMap<String, TutorialClient> _inTutorial;
private final TutorialType _type;
protected boolean _doScoreboard;
protected boolean _ghostMode;
public Tutorial(final int rewardAmount, final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final TutorialManager manager, final TutorialType type)
{
@ -58,6 +63,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_tasks = new HashMap<>();
_inTutorial = new HashMap<>();
_nameToTask = new HashMap<>();
_manager.getPluginManager().registerEvents(this, _manager.getPlugin());
}
public ArrayList<String> getLines(final ScoreboardManager manager, final Player player, final ArrayList<String> out)
@ -71,7 +78,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
out.clear();
final PlayerTutorial ptutorial = _inTutorial.get(player.getName());
final TutorialClient ptutorial = _inTutorial.get(player.getName());
lines.add(C.cAqua + _type.getFriendlyName() + " Tutorial");
@ -174,6 +181,42 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return _type;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPickupItem(final PlayerPickupItemEvent event)
{
if (_ghostMode && isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDropItem(final PlayerDropItemEvent event)
{
if (_ghostMode && isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBreakBlock(final BlockBreakEvent event)
{
if (_ghostMode && isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlaceBlock(final BlockPlaceEvent event)
{
if (_ghostMode && isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
private void finishFor(final Player player)
{
_inTutorial.remove(player.getName());
@ -190,10 +233,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_goldManager.addGold(player, _rewardAmount);
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_rewardAmount + " Gold") + "."));
for (Player other : UtilServer.getPlayers())
if (_ghostMode)
{
other.showPlayer(player);
player.showPlayer(other);
for (Player other : UtilServer.getPlayers())
{
other.showPlayer(player);
player.showPlayer(other);
}
}
for (int i = 0; i < 8; i++)
@ -224,13 +270,16 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void startFor(final Player player)
{
_inTutorial.put(player.getName(), PlayerTutorial.create(player, _taskManager, this));
_inTutorial.put(player.getName(), TutorialClient.create(player, _taskManager, this));
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
for (Player other : UtilServer.getPlayers())
if (_ghostMode)
{
other.hidePlayer(player);
player.hidePlayer(other);
for (Player other : UtilServer.getPlayers())
{
other.hidePlayer(player);
player.hidePlayer(other);
}
}
onBegin(player);
@ -240,10 +289,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{
_inTutorial.remove(player.getName());
for (Player other : UtilServer.getPlayers())
if (_ghostMode)
{
other.showPlayer(player);
player.showPlayer(other);
for (Player other : UtilServer.getPlayers())
{
other.showPlayer(player);
player.showPlayer(other);
}
}
}
@ -267,7 +319,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
return _taskManager.hasCompletedTask(player, _type.getId());
}
public PlayerTutorial get(final Player player)
public TutorialClient get(final Player player)
{
return _inTutorial.get(player.getName());
}

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilServer;
import mineplex.core.task.TaskManager;
public class PlayerTutorial
public class TutorialClient
{
private final TaskManager _taskManager;
private final Tutorial _tutorial;
@ -16,16 +16,16 @@ public class PlayerTutorial
private final HashMap<String, Object> _data = new HashMap<>();
private int _currentTask = 1;
public PlayerTutorial(final Player player, final TaskManager taskManager, final Tutorial tutorial)
public TutorialClient(final Player player, final TaskManager taskManager, final Tutorial tutorial)
{
_player = player;
_taskManager = taskManager;
_tutorial = tutorial;
}
public static PlayerTutorial create(final Player player, final TaskManager taskManager, final Tutorial tutorial)
public static TutorialClient create(final Player player, final TaskManager taskManager, final Tutorial tutorial)
{
final PlayerTutorial user = new PlayerTutorial(player, taskManager, tutorial);
final TutorialClient user = new TutorialClient(player, taskManager, tutorial);
for (final int i : tutorial.getTasks().keySet())
{
@ -76,21 +76,26 @@ public class PlayerTutorial
return task.getID() < _currentTask;
}
public <T> T getData(final String name, final T defValue)
public Object getData(final String name, final Object defValue)
{
if (!_data.containsKey(name)) _data.put(name, defValue);
return (T) _data.get(name);
return getData(name);
}
public <T> T getData(final String name)
public Object getData(final String name)
{
return (T) _data.get(name);
return _data.get(name);
}
public <T> void setData(final String name, final T value)
public void setData(final String name, final Object value)
{
_data.put(name, value);
}
public HashMap<String, Object> getData()
{
return _data;
}
}

View File

@ -37,8 +37,6 @@ public class TutorialManager extends MiniPlugin
_tutorials.put(TutorialType.GETTING_STARTED, new TutorialGettingStarted(this, clansManager, goldManager, taskManager));
_tutorials.put(TutorialType.ON_GOING, new TutorialOnGoingMap(this, clansManager, goldManager, taskManager));
registerEvents(_tutorials.get(TutorialType.GETTING_STARTED));
}
public void addCommands()

View File

@ -1,24 +1,27 @@
package mineplex.game.clans.tutorials.types;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
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.UtilItem.ArmourMaterial;
import mineplex.core.common.util.UtilItem.ItemCategory;
import mineplex.core.common.util.UtilPlayer;
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.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.PlayerTutorial;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialClient;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
@ -31,19 +34,19 @@ public class TutorialGettingStarted extends Tutorial
super(50, goldManager, taskManager, clansManager, manager, TutorialType.GETTING_STARTED);
addTask(1, "Welcome", "Welcome to Clans! Before you start playing Clans, you need to create a Clan by typing {/c create [name]}! Don't worry though, at the end of this tutorial, you will be disbanding this clan.");
addTask(2, "Create A Clan", "To create your own clan, type {/c create [name]}. Dont worry about your friends though, you can always disband this clan and join another later if you need to!");
addTask(3, "Viewing Clan Info", "Now you can view information about your clan. To do this type {/c [name]}! You can also use any clans name to get some information about them as well.");
addTask(4, "Leave Spawn", "Now you can leave the Spawn Island. Don't worry, you wont get hurt from the fall! Once you jump off though, PvP is enabled! Be careful!");
addTask(5, "Go To The Wilderness", "Access your map with {/map} and head out into the wilderness! Youll see various other locations marked on your map later.");
addTask(6, "Claiming Territory", "In order to claim a chunk of land for your clan you type {/c claim}! Notice though, your clan runs on energy! You can buy energy from the shops!", "Good job! We won't claim this area just yet, you may do it again later when you find a nice location.");
addTask(7, "Visit The Shops", "At the shops you can buy most things you need! Once a day you can transfer 1000 gems to 5000 clans gold here as well!");
addTask(8, "Buy Armor", "Head to the PvP Gear villager and purchase a set of armor! Make sure to buy a matching set to access your class skills!");
addTask(9, "Equip Armor", "In order to equip a kit, you must put on the full armor set of that kit! Put on the armor set you just bought and you will have selected your kit!");
addTask(10, "Use An Ability", "In order to use abilities you need a sword or axe. To use your sword ability, right click with your sword! To use your axe ability, right click with your axe!");
addTask(11, "Class Customization", "To customize your class, right click an enchantment table! There you will find the GUI for all the skills in that class! Customize it to your liking!");
addTask(12, "Clan Home", "In order to set a clan home, type {/c sethome}. You can only use {/c home} from the spawn island every 5 minutes to return home!");
addTask(2, "Viewing Clan Info", "Now you can view information about your clan. To do this type {/c [name]}! You can also use any clans name to get some information about them as well.");
addTask(3, "Leave Spawn", "Now you can leave the Spawn Island. Don't worry, you wont get hurt from the fall! Once you jump off though, PvP is enabled! Be careful!");
addTask(4, "Go To The Wilderness", "Access your map with {/map} and head out into the wilderness! Youll see various other locations marked on your map later.");
addTask(5, "Claiming Territory", "In order to claim a chunk of land for your clan you type {/c claim}! Notice though, your clan runs on energy! You can buy energy from the shops!", "Good job! We won't claim this area just yet, you can do it again later when you find a nice location.");
addTask(6, "Visit The Shops", "At the shops you can buy most things you need! Once a day you can transfer 1000 gems to 5000 clans gold here as well!");
addTask(7, "Buy Armor", "Head to the PvP Gear villager and purchase a set of armor! Make sure to buy a matching set to access your class skills!");
addTask(8, "Equip Armor", "In order to equip a kit, you must put on the full armor set of that kit! Put on the armor set you just bought and you will have selected your kit!");
addTask(9, "Use An Ability", "In order to use abilities you need a sword or axe. To use your sword ability, right click with your sword! To use your axe ability, right click with your axe!");
addTask(10, "Class Customization", "To customize your class, right click an enchantment table! There you will find the GUI for all the skills in that class! Customize it to your liking!");
addTask(11, "Disband Clan", "To disband your own clan, you can do {/c disband}, this will delete your clan, and you will be able to start a new one!");
_doScoreboard = true;
_ghostMode = true;
}
public void onFinished(final Player player)
@ -51,45 +54,98 @@ public class TutorialGettingStarted extends Tutorial
UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game."));
}
@EventHandler
public void onCommandPreprocess(final PlayerCommandPreprocessEvent event)
public boolean nullPrices(ItemStack item, final Player player)
{
if (event.getMessage().startsWith("/c help") || event.getMessage().startsWith("/clans help") || event.getMessage().startsWith("/clan help") || event.getMessage().startsWith("/factions help"))
if (!isInTutorial(player))
{
if (isInTutorial(event.getPlayer()) && !hasFinishedTask(event.getPlayer(), "Welcome"))
return false;
}
TutorialClient client = get(player);
if (UtilItem.isWeapon(item))
{
boolean hasBoughtWeapon = false;
for (Material material : UtilItem.listIn(ItemCategory.WEAPON))
{
finishTask(event.getPlayer(), "Welcome");
if (client.getData().containsKey(material.name() + "_bought"))
{
hasBoughtWeapon = true;
break;
}
}
return !hasBoughtWeapon;
}
else if (UtilItem.isArmour(item))
{
boolean hasBoughtSet = false;
ArmourMaterial armourBought = null;
int armourBoughtAmount = 0;
for (Material armour : UtilItem.listIn(ItemCategory.ARMOUR))
{
if (client.getData().containsKey(armour.name() + "_bought"))
{
ArmourMaterial armourType = ArmourMaterial.of(armour);
if (armourBought != null && !armourType.equals(armourBought))
{
continue;
}
armourBought = armourType;
armourBoughtAmount++;
if (armourBoughtAmount == 3)
{
hasBoughtSet = true;
}
}
}
return !hasBoughtSet;
}
else
{
return false;
}
}
public void onClanCreated(final String caller, final String name)
{
if (isInTutorial(caller) && get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask("Welcome")) && !get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask("Create A Clan")))
if (isInTutorial(caller) && !get(Bukkit.getPlayer(caller)).hasFinishedTask(getTask("Welcome")))
{
finishTask(Bukkit.getPlayer(caller), "Create A Clan");
finishTask(Bukkit.getPlayer(caller), "Welcome");
}
}
public void onClanInfo(final Player caller, final String name)
{
if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask("Create A Clan")) && !get(caller).hasFinishedTask(getTask("Viewing Clan Info")))
if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask("Welcome")) && !get(caller).hasFinishedTask(getTask("Viewing Clan Info")))
{
finishTask(caller, "Viewing Clan Info");
}
}
public void onEnterTerritory(final Player player, final String ownerString)
@EventHandler
public void onTerritory(final PlayerEnterTerritoryEvent event)
{
if (isInTutorial(player) && ownerString.contains("Spawn") && get(player).hasFinishedTask(getTask(3)) && !get(player).hasFinishedTask(getTask("Leave Spawn")))
final Player player = event.getPlayer();
final String oldTerritory = event.getLastTerritory();
final String newTerritory = event.getNewTerritory();
System.out.println(oldTerritory + ", " + newTerritory);
if (isInTutorial(player) && newTerritory.contains("Spawn") && get(player).hasFinishedTask(getTask(3)) && !get(player).hasFinishedTask(getTask("Leave Spawn")))
{
finishTask(player, "Leave Spawn");
}
else if (isInTutorial(player) && ownerString.contains("Wilderness") && get(player).hasFinishedTask(getTask(4)) && !get(player).hasFinishedTask(getTask("Go To The Wilderness")))
else if (isInTutorial(player) && newTerritory.contains("Wilderness") && get(player).hasFinishedTask(getTask(4)) && !get(player).hasFinishedTask(getTask("Go To The Wilderness")))
{
finishTask(player, "Go To The Wilderness");
}
else if (isInTutorial(player) && ownerString.contains("Shops") && get(player).hasFinishedTask(getTask(6)) && !get(player).hasFinishedTask(getTask("Visit The Shops")))
else if (isInTutorial(player) && newTerritory.contains("Shops") && get(player).hasFinishedTask(getTask(6)) && !get(player).hasFinishedTask(getTask("Visit The Shops")))
{
finishTask(player, "Visit The Shops");
}
@ -111,13 +167,26 @@ public class TutorialGettingStarted extends Tutorial
{
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Visit The Shops")) && !get(player).hasFinishedTask(getTask("Buy Armor")))
{
if (get(player).getData("amount", 0) < 3)
if (UtilItem.isArmour(item) || UtilItem.isWeapon(item))
{
get(player).setData("amount", get(player).<Integer> getData("amount") + 1);
}
else
{
finishTask(player, "Buy Armor");
int amount = 0;
for (Material material : UtilItem.listIn(ItemCategory.ARMOUR, ArmourMaterial.of(item.getType()).asCategory()))
{
if (get(player).getData().containsKey(material.name() + "_bought"))
{
amount++;
}
}
if (amount < 3)
{
get(player).setData("amount", ((int) get(player).getData("amount")) + 1);
get(player).setData(item.getType() + "_bought", true);
}
else
{
finishTask(player, "Buy Armor");
}
}
}
}
@ -176,7 +245,7 @@ public class TutorialGettingStarted extends Tutorial
{
if (event.getType().equals(UpdateType.SEC))
{
for (final PlayerTutorial tut : _inTutorial.values())
for (final TutorialClient tut : _inTutorial.values())
{
if (isInTutorial(tut.getPlayer()) && get(tut.getPlayer()).hasFinishedTask(getTask("Use An Ability")) && !get(tut.getPlayer()).hasFinishedTask(getTask("Class Customization")))
{
@ -191,13 +260,11 @@ public class TutorialGettingStarted extends Tutorial
}
}
public void onHomeSet(final String name)
public void onDeletedClan(final Player player)
{
final Player player = Bukkit.getPlayer(name);
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Class Customization")) && !get(player).hasFinishedTask(getTask("Clan Home")))
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Class Customization")) && !get(player).hasFinishedTask(getTask("Disband Clan")))
{
finishTask(player, "Clan Home");
finishTask(player, "Disband Clan");
}
}

View File

@ -1,12 +1,14 @@
package mineplex.game.clans.tutorials.types;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.Tutorial;
import mineplex.game.clans.tutorials.TutorialManager;
@ -21,23 +23,28 @@ public class TutorialOnGoingMap extends Tutorial
_doScoreboard = false;
}
public void onEnterTerritory(final Player player, final String ownerString)
@EventHandler
public void onEnterTerritory(final PlayerEnterTerritoryEvent event)
{
final Player player = event.getPlayer();
final String oldTerritory = event.getLastTerritory();
final String newTerritory = event.getNewTerritory();
if (!_taskManager.hasCompletedTask(player, "ClansOnGoingOptOut"))
{
if (ownerString.contains("Fields"))
if (newTerritory.equals("Fields"))
{
UtilPlayer.message(player, C.cRedB + "Warning! You're now entering the Fields!");
UtilPlayer.message(player, C.cRed + "Fields is a very lucrative area, filled with ores that periodically respawn over time. This is a great place to get a large amount of resources for your clan; however, be aware of other clans who may also be after the riches buried within the fields.");
UtilPlayer.message(player, C.cGray + "(To opt out of these messages, type " + F.elem("/optout") + ".)");
}
else if (ownerString.contains("Shop"))
else if (newTerritory.equals("Shop"))
{
UtilPlayer.message(player, C.cGreenB + "Welcome the Shops!");
UtilPlayer.message(player, C.cGreen + "Shops is a safe area where combat is disabled between players! Use this safety to purchase food, building blocks, armor, weapons, and other valuable resources. Be careful when leaving though, others may be hiding just outside the gates, eager to steal your recent purchases.");
UtilPlayer.message(player, C.cGray + "(To opt out of these messages, type " + F.elem("/optout") + ".)");
}
else if (ownerString.contains("Borderlands"))
else if (newTerritory.equals("Borderlands"))
{
UtilPlayer.message(player, C.cRedB + "Warning! You're now entering the Borderlands!");
UtilPlayer.message(player, C.cRed + "The Borderlands are the very outer reaches of the maps. Be careful as very powerful boss monsters will periodically spawn out here! Don't try to fight them alone! If you do manage to slay one of these powerful beasts, you'll be handsomely rewarded with powerful gear or legendary weapons.");