Forgot Achievement Manager

This commit is contained in:
Sam 2017-09-01 16:21:46 +01:00
parent 7e3e2b9ece
commit c520d605bf

View File

@ -8,11 +8,13 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.achievement.command.StatsCommand;
import mineplex.core.achievement.leveling.LevelingManager;
import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.common.Rank;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
@ -23,6 +25,16 @@ import mineplex.core.stats.event.StatChangeEvent;
public class AchievementManager extends MiniPlugin
{
public enum Perm implements Permission
{
FAKE_LEVEL_50,
FAKE_LEVEL_30,
FAKE_LEVEL_15,
FAKE_LEVEL_5,
SEE_FULL_STATS,
STATS_COMMAND,
}
private CoreClientManager _clientManager;
private IncognitoManager _incognitoManager;
private StatsManager _statsManager;
@ -33,7 +45,7 @@ public class AchievementManager extends MiniPlugin
private boolean _giveInterfaceItem = false;
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<>();
private boolean _shopEnabled = true;
public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognitoManager, EloManager eloManager)
@ -47,6 +59,18 @@ public class AchievementManager extends MiniPlugin
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
new LevelingManager(this);
generatePermissions();
}
private void generatePermissions()
{
PermissionGroup.MOD.setPermission(Perm.SEE_FULL_STATS, true, true);
PermissionGroup.MOD.setPermission(Perm.FAKE_LEVEL_5, true, true);
PermissionGroup.SRMOD.setPermission(Perm.FAKE_LEVEL_15, true, true);
PermissionGroup.ADMIN.setPermission(Perm.FAKE_LEVEL_30, true, true);
PermissionGroup.LT.setPermission(Perm.FAKE_LEVEL_50, true, true);
PermissionGroup.PLAYER.setPermission(Perm.STATS_COMMAND, true, true);
}
public AchievementData get(Player player, Achievement type)
@ -187,37 +211,44 @@ public class AchievementManager extends MiniPlugin
{
if (required == null || required.length == 0)
return false;
for (Achievement cur : required)
{
if (get(player, cur).getLevel() < cur.getMaxLevel())
return false;
}
return true;
}
public int getMineplexLevelNumber(Player sender, Rank rank)
public int getMineplexLevelNumber(Player sender)
{
CoreClient client = _clientManager.Get(sender);
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
if (rank.has(Rank.MODERATOR))
level = Math.max(level, 5);
if (rank.has(Rank.SNR_MODERATOR))
level = Math.max(level, 15);
if (rank.has(Rank.JNR_DEV))
level = Math.max(level, 25);
if (rank.has(Rank.ADMIN))
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
if (rank.has(Rank.OWNER))
if (client.hasPermission(Perm.FAKE_LEVEL_50))
{
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
}
else if (client.hasPermission(Perm.FAKE_LEVEL_30))
{
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
}
else if (client.hasPermission(Perm.FAKE_LEVEL_15))
{
level = Math.max(level, 15);
}
else if (client.hasPermission(Perm.FAKE_LEVEL_5))
{
level = Math.max(level, 5);
}
return level;
}
public String getMineplexLevel(Player sender, Rank rank)
{
return Achievement.getExperienceString(getMineplexLevelNumber(sender, rank)) + " " + ChatColor.RESET;
public String getMineplexLevel(Player sender)
{
return Achievement.getExperienceString(getMineplexLevelNumber(sender)) + " " + ChatColor.RESET;
}
public CoreClientManager getClientManager()
@ -239,4 +270,4 @@ public class AchievementManager extends MiniPlugin
{
return _statsManager;
}
}
}