GameAchievementManager now utilises TaskManager to record whether or not people have previously completed Achievements

This commit is contained in:
Chiss 2014-08-23 15:04:43 +10:00
parent e40cb17e47
commit 3ec43f90e8
6 changed files with 37 additions and 48 deletions

View File

@ -1,5 +1,7 @@
package mineplex.core.achievement;
import org.bukkit.ChatColor;
public class AchivementData
{
private int _level;

View File

@ -33,7 +33,7 @@ public class MorphBlock extends MorphGadget
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Change Block",
C.cYellow + "Stay Still" + C.cGray + " to use " + C.cGreen + "Solidify",
},
40000,
30000,
ArmorSlot.Helmet, Material.EMERALD_BLOCK, (byte)0);
}

View File

@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
@ -40,6 +41,8 @@ public class MorphPumpkinKing extends MorphGadget
disguise.SetCustomNameVisible(true);
disguise.SetSkeletonType(SkeletonType.WITHER);
Manager.getDisguiseManager().disguise(disguise);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{

View File

@ -1,46 +0,0 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSnowman;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
public class MorphSnowman extends MorphGadget
{
public MorphSnowman(GadgetManager manager)
{
super(manager, "Snowmans Head", new String[]
{
C.cWhite + "Transforms the wearer into",
C.cWhite + "a Christmas Snowman!",
"",
C.cYellow + "Earned by defeating the Pumpkin King",
C.cYellow + "in the 2013 Christmas Chaos Event.",
},
-1,
ArmorSlot.Helmet, Material.SNOW_BLOCK, (byte)0);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguiseSnowman disguise = new DisguiseSnowman(player);
disguise.SetName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
}

View File

@ -77,6 +77,7 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.timing.TimingManager;
@ -118,6 +119,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private SkillFactory _skillFactory;
private ClassShopManager _classShopManager;
private ClassCombatShop _classShop;
private TaskManager _taskManager;
private EloManager _eloManager;
@ -204,6 +206,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
_statsManager = new StatsManager(plugin);
_taskManager = new TaskManager(plugin, webAddress);
_achievementManager = new AchievementManager(_statsManager);
_inventoryManager = inventoryManager;
_cosmeticManager = cosmeticManager;
@ -345,6 +348,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _gameLobbyManager;
}
public TaskManager GetTaskManager()
{
return _taskManager;
}
public ArcadeShop GetShop()
{

View File

@ -6,6 +6,7 @@ import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementLog;
import mineplex.core.achievement.AchivementData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
@ -88,7 +89,28 @@ public class GameAchievementManager implements Listener
String nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel());
String progress = F.elem(C.cGreen + "+" + log.get(type).Amount);
if (log.get(type).LevelUp)
//Completed Achievement
if (data.getLevel() == type.getMaxLevel())
{
//Finishing for the first time
if (!Manager.GetTaskManager().hasCompletedTask(player, type.getName()))
{
UtilPlayer.message(player, nameLevel + " " + progress +
" " + F.elem(C.cAqua + C.Bold + "COMPLETE!"));
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
//Set Completed
Manager.GetTaskManager().completedTask(player, type.getName());
}
else
{
UtilPlayer.message(player, nameLevel + " " + progress +
" " + F.elem(C.cYellow + C.Bold + "Complete"));
}
}
//Multi-Level Achievements
else if (log.get(type).LevelUp)
{
UtilPlayer.message(player, nameLevel + " " + progress +
" " + F.elem(C.cAqua + C.Bold + "LEVEL UP!"));