More implementation of xp toggles for kit progression, and display achievement rewards properly for tiered leveling

This commit is contained in:
AlexTheCoder 2017-05-04 19:00:47 -04:00
parent 97a4b8e94d
commit 455e09a9da
2 changed files with 88 additions and 21 deletions

View File

@ -1,11 +1,18 @@
package nautilus.game.arcade.managers; package nautilus.game.arcade.managers;
import org.bukkit.ChatColor;
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.player.PlayerJoinEvent;
import mineplex.core.achievement.Achievement; import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementData; import mineplex.core.achievement.AchievementData;
import mineplex.core.achievement.AchievementLog; import mineplex.core.achievement.AchievementLog;
import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -16,14 +23,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import org.bukkit.ChatColor;
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.player.PlayerJoinEvent;
public class GameAchievementManager implements Listener public class GameAchievementManager implements Listener
{ {
ArcadeManager Manager; ArcadeManager Manager;
@ -84,13 +83,21 @@ public class GameAchievementManager implements Listener
//Display //Display
for (final Achievement type : log.keySet()) for (final Achievement type : log.keySet())
{ {
AchievementData data = Manager.GetAchievement().get(player, type); AchievementData data = Manager.GetAchievement().get(player, type);
String nameLevel = F.elem(C.cGold + C.Bold + type.getName()); String nameLevel = F.elem(C.cGold + C.Bold + type.getName());
if (type.getMaxLevel() > 1) if (type.getMaxLevel() > 1)
{
if (type.hasLevelNames())
{
String tier = data.getLevel() == 0 ? type.getDefaultLevelName() : type.getLevelNames()[Math.min(data.getLevel(), type.getLevelNames().length) - 1];
nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + "Tier: " + tier);
}
else
{
nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel()); 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); String progress = F.elem(C.cGreen + "+" + log.get(type).Amount);
@ -102,17 +109,51 @@ public class GameAchievementManager implements Listener
//Finishing for the first time //Finishing for the first time
if (!Manager.GetTaskManager().hasCompletedTask(player, type.getName())) if (!Manager.GetTaskManager().hasCompletedTask(player, type.getName()))
{ {
int gems = type.getGemReward();
int crowns = 0;
int xp = 0;
if (type.getLevelUpRewards().length > 0)
{
int[] rewards = type.getLevelUpRewards()[type.getLevelUpRewards().length - 1];
gems += rewards[0];
crowns += rewards[1];
xp += rewards[2];
}
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
UtilPlayer.message(player, nameLevel + " " + F.elem(C.cAqua + C.Bold + "Completed!") + String inform = nameLevel + " " + F.elem(C.cAqua + C.Bold + "Completed!");
" " + F.elem(C.cGreen + C.Bold + "+" + type.getGemReward() + " Gems")); if (gems > 0)
{
inform += " " + F.elem(C.cGreen + C.Bold + "+" + gems + " Gems");
}
if (crowns > 0)
{
inform += " " + F.elem(C.cGold + C.Bold + "+" + crowns + " Crowns");
}
if (xp > 0 && !Manager.GetTaskManager().hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName()))
{
inform += " " + F.elem(C.cYellow + C.Bold + "+" + xp + " XP");
}
UtilPlayer.message(player, inform);
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
Manager.GetTaskManager().completedTask(new Callback<Boolean>() final int finalGems = gems;
final int finalCrowns = crowns;
final int finalXp = xp;
Manager.GetTaskManager().completedTask(completed ->
{ {
public void run(Boolean completed) if (finalGems > 0)
{ {
Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, type.getName(), type.getGemReward()); Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, type.getName(), finalGems);
}
if (finalCrowns > 0)
{
Manager.GetDonation().rewardCrowns(finalCrowns, player);
}
if (finalXp > 0)
{
Manager.GetStatsManager().incrementStat(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], finalXp);
} }
}, player, type.getName()); }, player, type.getName());
} }
@ -125,9 +166,31 @@ public class GameAchievementManager implements Listener
//Multi-Level Achievements //Multi-Level Achievements
else if (log.get(type).LevelUp) else if (log.get(type).LevelUp)
{ {
int gems = 0;
int crowns = 0;
int xp = 0;
if (type.getLevelUpRewards().length > 0)
{
int[] rewards = type.getLevelUpRewards()[Math.min(data.getLevel(), type.getLevelUpRewards().length) - 1];
gems += rewards[0];
crowns += rewards[1];
xp += rewards[2];
}
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
UtilPlayer.message(player, nameLevel + " " + progress + String inform = nameLevel + " " + progress + " " + F.elem(C.cAqua + C.Bold + "LEVEL UP!");
" " + F.elem(C.cAqua + C.Bold + "LEVEL UP!")); if (gems > 0)
{
inform += " " + F.elem(C.cGreen + C.Bold + "+" + gems + " Gems");
}
if (crowns > 0)
{
inform += " " + F.elem(C.cGold + C.Bold + "+" + crowns + " Crowns");
}
if (xp > 0 && !Manager.GetTaskManager().hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName()))
{
inform += " " + F.elem(C.cYellow + C.Bold + "+" + xp + " XP");
}
UtilPlayer.message(player, inform);
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
} }

View File

@ -263,6 +263,10 @@ public class ProgressingKitManager implements Listener
{ {
return; return;
} }
if (!data.getKit().usesXp())
{
return;
}
player.sendMessage(SPACE); player.sendMessage(SPACE);