Achievements

This commit is contained in:
Sam 2017-06-05 20:57:30 +01:00
parent c3f3d71610
commit 4a91d2821b
10 changed files with 100 additions and 35 deletions

View File

@ -1201,7 +1201,31 @@ public enum Achievement
new String[]{"Skyfall.SupplyDropsOpened"},
new String[]{"Be the first to open 20 Supply Drops"},
new int[]{20},
AchievementCategory.SKYFALL);
AchievementCategory.SKYFALL),
GEM_HUNTERS_KILLS("Gem Killer", 5000,
new String[]{"Gem Hunters.Kills"},
new String[]{"+1 for each kill"},
new int[]{10,25,50,100,1000},
AchievementCategory.GEM_HUNTERS),
GEM_HUNTERS_GEMS_EARNED("Gem Millionaire", 5000,
new String[]{"Gem Hunters.GemsEarned"},
new String[]{"+1 for each Gem cashed out"},
new int[]{1000,2500,5000,10000,100000},
AchievementCategory.GEM_HUNTERS),
GEM_HUNTERS_QUESTS("Quest Complete", 5000,
new String[]{"Gem Hunters.QuestsOpened"},
new String[]{"+1 for each quest completed"},
new int[]{10,25,50,100,1000},
AchievementCategory.GEM_HUNTERS),
GEM_HUNTERS_CHESTS_OPENED("Loot Get!", 5000,
new String[]{"Gem Hunters.ChestsOpened"},
new String[]{"+1 for each chest opened"},
new int[]{50,100,200,400,1000},
AchievementCategory.GEM_HUNTERS);
private String _name;
private String[] _desc;

View File

@ -213,7 +213,11 @@ public enum AchievementCategory
StatDisplay.fromGame("Wins", GameDisplay.SkyfallTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkyfallTeams, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.SkyfallTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkyfallTeams, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.SkyfallTeams, "GemsEarned"), null, StatDisplay.fromGame("Booster Rings", GameDisplay.SkyfallTeams, "Rings")},
Material.DIAMOND_BOOTS, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId());
Material.DIAMOND_BOOTS, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId()),
GEM_HUNTERS("Gem Hunters", null,
new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Complete", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")},
Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId());
private String _name;
private String[] _statsToPull;

View File

@ -104,6 +104,8 @@ public enum GameDisplay
AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false),
GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false),
Brawl("Brawl", Material.DIAMOND, (byte) 0, GameCategory.EVENT, 998, false);

View File

@ -78,7 +78,7 @@ public class Track implements Listener
return this._trackRequirements;
}
public final String getStatName()
public String getStatName()
{
return "track." + _id;
}

View File

@ -59,4 +59,13 @@ public class GemHuntersTrack extends Track
getRequirements()
.withRequirement(1, "Gem Earned in Gem Hunters");
}
/**
* Overriding this means we can hit two birds with one stat.
*/
@Override
public String getStatName()
{
return "Gem Hunters.GemsEarned";
}
}

View File

@ -188,6 +188,7 @@ public class GemHunters extends JavaPlugin
// Creatures
Creature creature = new Creature(this);
creature.SetDisableCustomDrops(true);
// The old classic Damage Manager
DamageManager damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, new ConditionManager(this));

View File

@ -1,11 +1,20 @@
package mineplex.gemhunters.death;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.google.common.collect.Sets;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
import mineplex.gemhunters.playerstatus.PlayerStatusType;
import mineplex.gemhunters.spawn.SpawnModule;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -13,7 +22,6 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -22,25 +30,14 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.google.common.collect.Sets;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
import mineplex.gemhunters.playerstatus.PlayerStatusType;
import mineplex.gemhunters.spawn.SpawnModule;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* This module handles anything to do with a players death
@ -56,6 +53,7 @@ public class DeathModule extends MiniPlugin
private static final int DEATH_ANIMATION_COUNTDOWN = 2000;
private final PlayerStatusModule _playerStatus;
private final StatsManager _stats;
private final SpawnModule _spawn;
private final Map<UUID, Long> _toRemove;
@ -65,6 +63,7 @@ public class DeathModule extends MiniPlugin
super("Death");
_playerStatus = require(PlayerStatusModule.class);
_stats = require(StatsManager.class);
_spawn = require(SpawnModule.class);
_toRemove = new HashMap<>();
@ -80,6 +79,14 @@ public class DeathModule extends MiniPlugin
player.setFoodLevel(20);
player.setExhaustion(0);
// Record the stats
Player killer = player.getKiller();
if (killer != null)
{
_stats.incrementStat(player, "Gem Hunters.Kills", 1);
}
startAnimation(player);
_toRemove.put(player.getUniqueId(), System.currentTimeMillis());
}

View File

@ -3,16 +3,20 @@ package mineplex.gemhunters.economy;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Intent;
import mineplex.core.portal.Portal;
import mineplex.core.recharge.Recharge;
import mineplex.core.titles.tracks.TrackManager;
import mineplex.core.titles.tracks.standard.GemHuntersTrack;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.economy.command.CashOutItemCommand;
@ -32,7 +36,12 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import java.text.DecimalFormat;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ReflectivelyCreateMiniPlugin
public class CashOutModule extends MiniPlugin
@ -46,7 +55,7 @@ public class CashOutModule extends MiniPlugin
private static final int CASH_OUT_MAX_MOVE_DISTANCE_SQUARED = 4;
private final DonationManager _donation;
private final TrackManager _track;
private final StatsManager _stats;
private final Map<UUID, CashOutSession> _sessions;
private final Set<UUID> _aboutToCashOut;
@ -56,7 +65,7 @@ public class CashOutModule extends MiniPlugin
super("Cash Out");
_donation = require(DonationManager.class);
_track = require(TrackManager.class);
_stats = require(StatsManager.class);
_sessions = new HashMap<>();
_aboutToCashOut = new HashSet<>();
@ -151,7 +160,7 @@ public class CashOutModule extends MiniPlugin
_aboutToCashOut.add(player.getUniqueId());
_track.getTrack(GemHuntersTrack.class).incrementFor(player, completeEvent.getGems());
_stats.incrementStat(player, "Gem Hunters.GemsEarned", completeEvent.getGems());
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems());
session.endSession();

View File

@ -5,6 +5,7 @@ import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.google.GoogleSheetsManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.economy.EconomyModule;
@ -58,6 +59,7 @@ public class LootModule extends MiniPlugin
private final EconomyModule _economy;
private final GoogleSheetsManager _sheets;
private final SafezoneModule _safezone;
private final StatsManager _stats;
private final WorldDataModule _worldData;
private final Map<String, Set<LootItem>> _chestLoot;
@ -73,6 +75,7 @@ public class LootModule extends MiniPlugin
_economy = require(EconomyModule.class);
_sheets = require(GoogleSheetsManager.class);
_safezone = require(SafezoneModule.class);
_stats = require(StatsManager.class);
_worldData = require(WorldDataModule.class);
_chestLoot = new HashMap<>();
_chestProperties = new HashMap<>();
@ -454,6 +457,7 @@ public class LootModule extends MiniPlugin
return;
}
_stats.incrementStat(player, "Gem Hunters.ChestsOpened", 1);
fillChest(player, block, key);
}

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import mineplex.core.common.util.*;
import mineplex.core.stats.StatsManager;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
@ -87,6 +88,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
};
private final EconomyModule _economy;
private final StatsManager _stats;
private final WorldDataModule _worldData;
private QuestModule()
@ -94,6 +96,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
super("Quest");
_economy = require(EconomyModule.class);
_stats = require(StatsManager.class);
_worldData = require(WorldDataModule.class);
Menu<?> menu = new QuestUI(this);
@ -312,6 +315,8 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
player.sendMessage(F.main(_moduleName, "Completed " + F.name(quest.getName()) + "."));
_stats.incrementStat(player, "Gem Hunters.Quests Completed", 1);
QuestPlayerData playerData = Get(player);
playerData.getActiveQuests().remove(Integer.valueOf(quest.getId()));
playerData.getCompletedQuests().add(quest.getId());