A ton of tutorial work

This commit is contained in:
Shaun Bennett 2016-03-15 10:29:43 -05:00
parent e08ba29ac1
commit e53b8616d1
22 changed files with 490 additions and 227 deletions

View File

@ -0,0 +1,41 @@
package mineplex.core.common.block;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
public class DataLocationMap
{
private EnumMap<DyeColor, List<Location>> _dataMap;
public DataLocationMap()
{
_dataMap = new EnumMap<>(DyeColor.class);
}
public List<Location> getLocations(DyeColor color)
{
List<Location> list = _dataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addLocation(DyeColor color, Location location)
{
if (_dataMap.containsKey(color))
{
_dataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_dataMap.put(color, list);
}
}
}

View File

@ -1,9 +1,12 @@
package mineplex.core.common.block.schematic;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.block.DataLocationMap;
public class Schematic
{
private final short _width;
@ -21,8 +24,10 @@ public class Schematic
_blockData = blockData;
}
public void paste(Location originLocation)
public DataLocationMap paste(Location originLocation)
{
DataLocationMap locationMap = new DataLocationMap();
int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ();
@ -34,7 +39,6 @@ public class Schematic
for (int z = 0; z < _length; z++)
{
int index = getIndex(x, y, z);
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z);
// some blocks were giving me negative id's in the schematic (like stairs)
// not sure why but the math.abs is my simple fix
int materialId = Math.abs(_blocks[index]);
@ -42,13 +46,58 @@ public class Schematic
Material material = Material.getMaterial(materialId);
if (material == null)
{
System.out.println(materialId + " data: " + _blockData[index]);
System.err.println("Schematic: Could not find Material [id: " + materialId + " data: " + _blockData[index] + "]");
continue;
}
else if (material == Material.GOLD_PLATE)
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, originLocation, x, y - 1, z))
continue;
}
else if (material == Material.WOOL)
{
// Check if this is a dataloc so we can skip setting the block
int aboveIndex = getIndex(x, y + 1, z);
if (hasIndex(aboveIndex))
{
if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId())
continue;
}
}
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z);
block.setTypeIdAndData(materialId, _blockData[index], false);
}
}
}
return locationMap;
}
/**
* Checks the schematic location for x, y, z and adds the a Location to the DataLocationMap if it is a wool block
*
* @return true if a location was added to the DataLocationMap
*/
private boolean addDataWool(DataLocationMap map, Location origin, int x, int y, int z)
{
int index = getIndex(x, y, z);
if (hasIndex(index))
{
int materialId = Math.abs(_blocks[index]);
if (materialId == 35) // WOOL
{
byte data = _blockData[index];
DyeColor color = DyeColor.getByWoolData(data);
if (color != null)
{
map.addLocation(color, origin.clone().add(x, y, z));
return true;
}
}
}
return false;
}
public int getSize()
@ -61,6 +110,11 @@ public class Schematic
return y * _width * _length + z * _width + x;
}
public boolean hasIndex(int index)
{
return index < _blocks.length;
}
public short getBlock(int x, int y, int z)
{
return _blocks[getIndex(x, y, z)];
@ -99,6 +153,6 @@ public class Schematic
@Override
public String toString()
{
return String.format("width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d", _width, _length, _height, _blocks.length, _blockData.length);
return String.format("Schematic [width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d]", _width, _length, _height, _blocks.length, _blockData.length);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.common.generator;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
public class VoidGenerator extends ChunkGenerator
{
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{
return createChunkData(world);
}
}

View File

@ -13,32 +13,39 @@ import org.bukkit.plugin.java.JavaPlugin;
/**
* An Objective represents a set of goals that need to be completed to move on to the next Objective in the quest
*/
public abstract class Objective<Data extends ObjectiveData> implements Listener
public abstract class Objective<Plugin, Data extends ObjectiveData> implements Listener
{
private JavaPlugin _plugin;
private Plugin _plugin;
private JavaPlugin _javaPlugin;
private String _name;
private String _description;
private HashMap<UUID, Data> _active;
private List<ObjectiveListener> _listeners;
public Objective(JavaPlugin plugin, String name, String description)
public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
_plugin = plugin;
_javaPlugin = javaPlugin;
_name = name;
_description = description;
_active = new HashMap<>();
_listeners = new LinkedList<>();
plugin.getServer().getPluginManager().registerEvents(this, plugin);
javaPlugin.getServer().getPluginManager().registerEvents(this, javaPlugin);
}
public JavaPlugin getPlugin()
public Plugin getPlugin()
{
return _plugin;
}
public JavaPlugin getJavaPlugin()
{
return _javaPlugin;
}
/**
* Get the name of this Objective
*/
@ -72,6 +79,8 @@ public abstract class Objective<Data extends ObjectiveData> implements Listener
_listeners.clear();
}
protected abstract void customStart(Player player);
/**
* Start this Objective for a player
* @param player
@ -88,8 +97,6 @@ public abstract class Objective<Data extends ObjectiveData> implements Listener
customStart(player);
}
protected abstract void customStart(Player player);
/**
* Leave this objective for a specific player
* This does not count as completing the object

View File

@ -7,13 +7,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class OrderedObjective extends Objective<OrderedObjectiveData>
public abstract class OrderedObjective<Plugin> extends Objective<Plugin, OrderedObjectiveData>
{
private List<ObjectiveGoal> _goals;
public OrderedObjective(JavaPlugin plugin, String name, String description)
public OrderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
super(plugin, name, description);
super(plugin, javaPlugin, name, description);
_goals = new ArrayList<>();
}
@ -22,7 +22,7 @@ public abstract class OrderedObjective extends Objective<OrderedObjectiveData>
{
_goals.add(goal);
getPlugin().getServer().getPluginManager().registerEvents(goal, getPlugin());
getJavaPlugin().getServer().getPluginManager().registerEvents(goal, getJavaPlugin());
}
@Override

View File

@ -6,13 +6,13 @@ import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class SingleObjective extends Objective<ObjectiveData>
public abstract class SingleObjective<Plugin> extends Objective<Plugin, ObjectiveData>
{
private final ObjectiveData _nullData;
public SingleObjective(JavaPlugin plugin, String name, String description)
public SingleObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
super(plugin, name, description);
super(plugin, javaPlugin, name, description);
_nullData = new ObjectiveData();
}

View File

@ -148,8 +148,6 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
{
_resourcePackUsers.remove(player.getName());
}
System.out.println("status: " + player.getName() + " " + event);
}
@EventHandler

View File

@ -140,8 +140,9 @@ public class ClansRegions extends MiniPlugin
public void claimArea(final String clanName, final int chunkRadius, final int claimOffset, final boolean safe, final boolean addNegative, final Location... locations)
{
final ClanInfo clan = _manager.getClan(clanName);
if (clan == null )
// Only claim if the clan doesn't exist yet. Speeds up startup time
if (clan == null)
{
_manager.getClanDataAccess().create("ClansRegions", clanName, true, new Callback<ClanInfo>()
{
@ -166,13 +167,6 @@ public class ClansRegions extends MiniPlugin
}
});
}
else
{
for (Location location : locations)
{
claimArea(clan, location, chunkRadius, claimOffset, addNegative, safe);
}
}
}
/*private void claimArea(String clanName, int chunkRadius, int claimOffset, boolean safe, Location... locations)

View File

@ -7,8 +7,10 @@ import java.util.List;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.Objective;
@ -24,6 +26,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
private ClansMessageManager _message;
private String _name;
private String _taskIdentifier;
private TutorialWorldManager _worldManager;
// GUI Data
private Material _guiMaterial;
@ -54,9 +57,15 @@ public abstract class Tutorial implements Listener, ObjectiveListener
public void start(Player player)
{
System.out.println(String.format("Tutorial> [%s] started tutorial [%s]", player.getName(), getName()));
_playerSessionMap.put(player, new TutorialSession());
TutorialSession session = new TutorialSession();
if (_worldManager != null)
session.setRegion(_worldManager.getNextRegion());
_playerSessionMap.put(player, session);
// Start at first objective!
setObjective(player, 0);
onStart(player);
}
private void setObjective(Player player, int objective)
@ -126,14 +135,49 @@ public abstract class Tutorial implements Listener, ObjectiveListener
private void finish(Player player)
{
_playerSessionMap.remove(player);
removePlayer(player);
System.out.println(String.format("Tutorial> [%s] finished tutorial [%s]", player.getName(), getName()));
onFinish();
onFinish(player);
}
protected abstract void onFinish();
private void quit(Player player)
{
removePlayer(player);
System.out.println(String.format("Tutorial> [%s] quit tutorial [%s]", player.getName(), getName()));
onQuit(player);
}
private void removePlayer(Player player)
{
TutorialSession session = _playerSessionMap.remove(player);
if (session != null)
{
if (session.getRegion() != null)
{
_worldManager.returnRegion(session.getRegion());
}
}
}
/**
* Called when the player finishes the tutorial
*/
protected abstract void onFinish(Player player);
/**
* Called when the player starts the tutorial
*/
protected abstract void onStart(Player player);
/**
* Called when a player quits the tutorial or leaves the game in the tutorial
*/
protected abstract void onQuit(Player player);
public void unregisterAll()
{
@ -153,10 +197,26 @@ public abstract class Tutorial implements Listener, ObjectiveListener
Objective currentObjective = _objectives.get(objectiveIndex);
lines.add(C.cGoldB + "Current Task (" + (objectiveIndex + 1) + "/" + _objectives.size() + ")");
lines.add(" " + currentObjective.getName());
lines.add(" ");
lines.add("Type /skip to exit tutorial");
}
return lines;
}
public void setWorldManager(TutorialWorldManager worldManager)
{
_worldManager = worldManager;
}
public TutorialRegion getRegion(Player player)
{
return _playerSessionMap.get(player).getRegion();
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
if (isInTutorial(event.getPlayer()))
{
quit(event.getPlayer());
}
}
}

View File

@ -5,9 +5,6 @@ import java.util.EnumMap;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -20,7 +17,7 @@ import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.command.TutorialCommand;
import mineplex.game.clans.tutorial.gui.TutorialShop;
import mineplex.game.clans.tutorial.tutorials.combat.CombatTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
public class TutorialManager extends MiniPlugin implements ScoreboardElement
{
@ -42,7 +39,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
_shopMap = new EnumMap<TutorialType, TutorialShop>(TutorialType.class);
addTutorial(TutorialType.COMBAT, new CombatTutorial(plugin, _clansMessageManager));
addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, _clansMessageManager));
}
@Override

View File

@ -0,0 +1,75 @@
package mineplex.game.clans.tutorial;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.block.schematic.Schematic;
public class TutorialRegion
{
private final Schematic _schematic;
private final Location _origin;
private DataLocationMap _locationMap;
protected TutorialRegion(Schematic schematic, Location origin)
{
_origin = origin;
_schematic = schematic;
pasteSchematic();
}
public Location getOrigin()
{
return _origin;
}
public DataLocationMap getLocationMap()
{
return _locationMap;
}
private void pasteSchematic()
{
_locationMap = _schematic.paste(getOrigin());
}
/**
* Clear the schematic area. This shouldn't be needed
*/
@Deprecated
private void clearSchematic()
{
for (int x = 0; x < _schematic.getWidth(); x++)
{
for (int y = 0; y < _schematic.getHeight(); y++)
{
for (int z = 0; z < _schematic.getLength(); z++)
{
Block b = _origin.clone().add(x, y, z).getBlock();
if (b.getType() != Material.AIR)
{
b.setTypeIdAndData(0, (byte) 0, false);
}
}
}
}
}
protected void reset()
{
long start = System.currentTimeMillis();
System.out.println("TutorialRegion starting reset...");
pasteSchematic();
System.out.println("TutorialRegion finished reset! Took " + (System.currentTimeMillis() - start) + "ms");
}
@Override
public String toString()
{
return "TutorialRegion[" + _origin.toString() + "]";
}
}

View File

@ -3,6 +3,7 @@ package mineplex.game.clans.tutorial;
public class TutorialSession
{
private int _objectiveIndex;
private TutorialRegion _region;
public TutorialSession()
{
@ -17,4 +18,14 @@ public class TutorialSession
{
_objectiveIndex = objectiveIndex;
}
public TutorialRegion getRegion()
{
return _region;
}
public void setRegion(TutorialRegion region)
{
_region = region;
}
}

View File

@ -2,5 +2,5 @@ package mineplex.game.clans.tutorial;
public enum TutorialType
{
COMBAT
MAIN
}

View File

@ -0,0 +1,100 @@
package mineplex.game.clans.tutorial;
import java.io.File;
import java.io.IOException;
import java.util.Stack;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.generator.VoidGenerator;
import mineplex.game.clans.tutorial.TutorialRegion;
public class TutorialWorldManager extends MiniPlugin
{
private final World _tutorialWorld;
private final Schematic _schematic;
private Stack<TutorialRegion> _regionStack;
public TutorialWorldManager(JavaPlugin plugin, String worldName, String schematicName) throws IOException
{
super("Tutorial World", plugin);
log("Creating Tutorial World");
WorldCreator creator = new WorldCreator(worldName);
creator.generator(new VoidGenerator());
_tutorialWorld = Bukkit.createWorld(creator);
_tutorialWorld.setDifficulty(Difficulty.PEACEFUL);
_tutorialWorld.setGameRuleValue("doDaylightCycle", "false");
_tutorialWorld.setTime(6000);
_tutorialWorld.setAutoSave(false);
_tutorialWorld.setAmbientSpawnLimit(0);
_tutorialWorld.setMonsterSpawnLimit(0);
_tutorialWorld.setWaterAnimalSpawnLimit(0);
log("Tutorial World Created!");
log("Loading schematic - " + schematicName);
_schematic = UtilSchematic.loadSchematic(new File(schematicName));
log("Finished loading schematic");
log("Populating Region Stack...");
populateRegionStack();
log("Finished loading Tutorial World Manager!");
}
private void populateRegionStack()
{
_regionStack = new Stack<>();
// Populate the stack with 100 available tutorial regions
for (int x = 0; x < 10; x++)
{
for (int z = 0; z < 10; z++)
{
double xLoc = (x - 5) * 100; // 100x100 regions
double zLoc = (z - 5) * 100;
_regionStack.add(new TutorialRegion(_schematic, new Location(_tutorialWorld, xLoc, 64, zLoc)));
}
}
}
/**
* Get the next TutorialRegion in the stack. This region is prepared and ready for use in a tutorial
* @return
*/
public TutorialRegion getNextRegion()
{
return _regionStack.pop();
}
/**
* Notify the TutorialWorldManager that this TutorialRegion is no longer needed and should be cleaned up.
* The TutorialRegion should not be used after calling this method
*/
public void returnRegion(TutorialRegion region)
{
region.reset();
_regionStack.push(region);
log("Returned " + region.toString());
}
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent event)
{
if (event.getPlayer().getName().contains("Phinary") && event.getMessage().contains("tw"))
{
event.getPlayer().teleport(new Location(_tutorialWorld, 0, 64, 0));
}
}
}

View File

@ -25,14 +25,17 @@ public class StartCommand extends CommandBase<TutorialManager>
return;
}
try
TutorialType type = null;
for (TutorialType check : TutorialType.values())
{
TutorialType type = TutorialType.valueOf(args[0]);
if (check.name().equalsIgnoreCase(args[0]))
type = check;
}
if (type != null)
Plugin.openTutorialMenu(caller, type);
}
catch (IllegalArgumentException ex)
{
UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial: " + F.elem(args[0])));
}
else
UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial " + F.elem(args[0])));
}
}

View File

@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.tutorial.TutorialManager;
public class TutorialCommand extends MultiCommandBase<TutorialManager>
@ -19,6 +21,6 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
@Override
protected void Help(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main("Tutorial", "/tutorial start <name>"));
}
}

View File

@ -0,0 +1,50 @@
package mineplex.game.clans.tutorial.tutorials.clans;
import java.io.IOException;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.TutorialWorldManager;
import mineplex.game.clans.tutorial.tutorials.clans.objective.LeaveSpawnObjective;
public class ClansMainTutorial extends Tutorial
{
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message)
{
super(plugin, message, "Clans Tutorial", "Clans.MainTutorial", Material.DIAMOND_SWORD, (byte) 0);
try
{
setWorldManager(new TutorialWorldManager(plugin, "main_tutorial", "schematic/ClansTutorial.schematic"));
}
catch (IOException e)
{
e.printStackTrace();
}
addObjective(new LeaveSpawnObjective(this, plugin));
}
@Override
protected void onFinish(Player player)
{
}
@Override
protected void onStart(Player player)
{
player.teleport(getRegion(player).getLocationMap().getLocations(DyeColor.RED).get(0));
}
@Override
protected void onQuit(Player player)
{
}
}

View File

@ -0,0 +1,33 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.SingleObjective;
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
protected void customStart(Player player)
{
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -1,28 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.Objective;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.tutorials.combat.objectives.CustomizeKitObjective;
import mineplex.game.clans.tutorial.tutorials.combat.objectives.EquipArmorObjective;
public class CombatTutorial extends Tutorial
{
public CombatTutorial(JavaPlugin plugin, ClansMessageManager message)
{
super(plugin, message, "Combat Tutorial", "combat", Material.DIAMOND_SWORD, (byte) 0);
addObjective(new EquipArmorObjective(plugin));
addObjective(new CustomizeKitObjective(plugin));
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,35 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat.objectives;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.combat.objectives.goals.OpenCustomizationGoal;
public class CustomizeKitObjective extends OrderedObjective
{
public CustomizeKitObjective(JavaPlugin plugin)
{
super(plugin, "Customize Kit", "Customize your kit");
addGoal(new OpenCustomizationGoal(this));
}
@Override
protected void customStart(Player player)
{
super.customStart(player);
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -1,77 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat.objectives;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.SingleObjective;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class EquipArmorObjective extends SingleObjective
{
public EquipArmorObjective(JavaPlugin plugin)
{
super(plugin, "Equip Armor", "Equip Armor");
}
@Override
protected void customStart(Player player)
{
player.getInventory().addItem(new ItemStack(Material.IRON_HELMET));
player.getInventory().addItem(new ItemStack(Material.IRON_CHESTPLATE));
player.getInventory().addItem(new ItemStack(Material.IRON_LEGGINGS));
player.getInventory().addItem(new ItemStack(Material.IRON_BOOTS));
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void checkArmor(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (UUID uuid : getActive())
{
Player player = UtilPlayer.searchExact(uuid);
if (player == null)
{
System.out.println("Tutorial Error: " + getName() + " has UUID with null player: " + uuid);
continue;
}
if (isEquipped(player))
finish(player);
}
}
private boolean isEquipped(Player player)
{
boolean equipped = true;
if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.IRON_HELMET ||
player.getInventory().getChestplate() == null || player.getInventory().getChestplate().getType() != Material.IRON_CHESTPLATE ||
player.getInventory().getLeggings() == null || player.getInventory().getLeggings().getType() != Material.IRON_LEGGINGS ||
player.getInventory().getBoots() == null || player.getInventory().getBoots().getType() != Material.IRON_BOOTS)
equipped = false;
return equipped;
}
}

View File

@ -1,37 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat.objectives.goals;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent;
public class OpenCustomizationGoal extends ObjectiveGoal
{
public OpenCustomizationGoal(Objective objective)
{
super(objective, "Open Customization", "Open Customization");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onOpenClassShop(OpenClassShopEvent event)
{
if (contains(event.getPlayer()))
{
finish(event.getPlayer());
}
}
}