UHC Achievements
This commit is contained in:
parent
ddab450c8e
commit
bb7191504c
@ -161,8 +161,6 @@ public enum Achievement
|
||||
new String[]{"Win a Game With No Armor"},
|
||||
new int[]{1},
|
||||
AchievementCategory.SKYWARS),
|
||||
|
||||
|
||||
|
||||
//UHC
|
||||
UHC_WINS("Ultimate Winner", 600,
|
||||
@ -170,7 +168,68 @@ public enum Achievement
|
||||
new String[]{"Win 10 games of Ultra Hardcore"},
|
||||
new int[]{10},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
|
||||
UHC_FOOD("Fine Dining", 1200,
|
||||
new String[]{"Ultra Hardcore.Food"},
|
||||
new String[]{"Collect and eat every type of food in a game"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
UHC_MINER("Lucky Minder", 1200,
|
||||
new String[]{"Ultra Hardcore.Miner"},
|
||||
new String[]{"Equip a full set of iron armor within 10 minutes of the game starting"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
UHC_HOE("I Don\'t Need This", 1200,
|
||||
new String[]{"Ultra Hardcore.Hoe"},
|
||||
new String[]{"Craft a diamond hoe"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
UHC_DIE("I Will Not Die!", 1200,
|
||||
new String[]{"Ultra Hardcore.Die"},
|
||||
new String[]{"Drop down to half a heart before healing back up"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
UHC_WOLF("Pack Tamer", 1200,
|
||||
new String[]{"Ultra Hardcore.WolfTame"},
|
||||
new String[]{"Tame a pack of at least 4 wolves and kill someone with them."},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
UHC_SPEED_FOOD("Fine Dining", 1200,
|
||||
new String[]{"Ultra Hardcore Speed.Food"},
|
||||
new String[]{"Collect and eat every type of food in a game"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC_SPEED),
|
||||
|
||||
UHC_SPEED_MINER("Lucky Minder", 1200,
|
||||
new String[]{"Ultra Hardcorev.Miner"},
|
||||
new String[]{"Equip a full set of iron armor within 10 minutes of the game starting"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC_SPEED),
|
||||
|
||||
UHC_SPEED_HOE("I Don\'t Need This", 1200,
|
||||
new String[]{"Ultra Hardcore Speed.Hoe"},
|
||||
new String[]{"Craft a diamond hoe"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC_SPEED),
|
||||
|
||||
UHC_SPEED_DIE("I Will Not Die!", 1200,
|
||||
new String[]{"Ultra Hardcore Speed.Die"},
|
||||
new String[]{"Drop down to half a heart before healing back up"},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC_SPEED),
|
||||
|
||||
UHC_SPEED_WOLF("Pack Tamer", 1200,
|
||||
new String[]{"Ultra Hardcore Speed.WolfTame"},
|
||||
new String[]{"Tame a pack of at least 4 wolves and kill someone with them."},
|
||||
new int[]{1},
|
||||
AchievementCategory.UHC_SPEED),
|
||||
|
||||
|
||||
//MC League
|
||||
/*MC_LEAGUE_STRIKE("First Strike", 600,
|
||||
new String[] {"MC League.FirstStrike"},
|
||||
|
@ -46,20 +46,36 @@ public enum AchievementCategory
|
||||
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHC.getGameId()),
|
||||
new StatDisplay[] {
|
||||
new StatDisplay(C.Bold + "Solo Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCSolo, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSolo, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCSolo, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSolo, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSolo, "GemsEarned"),
|
||||
null,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Teams Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHC, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHC, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHC, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHC, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHC, "GemsEarned") },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSolo.getGameId(), GameDisplay.UHC.getGameId()),
|
||||
|
||||
UHC_SOLO("Ultra Hardcore Solo", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSolo.getGameId()),
|
||||
|
||||
UHC_SOLO_SPPED("Ultra Hardcore Solo Speed", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSoloSpeed.getGameId()),
|
||||
|
||||
UHC_TEAMS_SPPED("Ultra Hardcore Teams Speed", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCTeamsSpeed.getGameId()),
|
||||
UHC_SPEED("Ultra Hardcore Speed", null,
|
||||
new StatDisplay[] {
|
||||
new StatDisplay(C.Bold + "Solo Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCSoloSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSoloSpeed, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCSoloSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSoloSpeed, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSoloSpeed, "GemsEarned"),
|
||||
null,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Teams Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCTeamsSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCTeamsSpeed, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCTeamsSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCTeamsSpeed, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCTeamsSpeed, "GemsEarned") },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSoloSpeed.getGameId(), GameDisplay.UHCTeamsSpeed.getGameId()),
|
||||
|
||||
/*MC_LEAGUE("MC League", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
|
@ -24,13 +24,13 @@ public class UHCMainPage extends AchievementMainPage
|
||||
{
|
||||
public UHCMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
|
||||
{
|
||||
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 5, targetName, targetStats);
|
||||
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 3 * 9, targetName, targetStats);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int slot = 10;
|
||||
int slot = 11;
|
||||
|
||||
for (AchievementCategory category : AchievementCategory.values())
|
||||
{
|
||||
@ -41,7 +41,7 @@ public class UHCMainPage extends AchievementMainPage
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _targetName, _targetStats);
|
||||
category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _targetName, _targetStats);
|
||||
lore.add(" ");
|
||||
addAchievements(category, lore, 9);
|
||||
lore.add(" ");
|
||||
@ -50,7 +50,7 @@ public class UHCMainPage extends AchievementMainPage
|
||||
ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false, false);
|
||||
addButton(slot, shopItem, button);
|
||||
|
||||
slot += ((slot + 1) % 9 == 0) ? 1 : 2;
|
||||
slot += 4;
|
||||
}
|
||||
|
||||
addBackButton();
|
||||
|
@ -82,7 +82,6 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.CombatLog;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
|
||||
@ -95,6 +94,11 @@ import nautilus.game.arcade.game.games.AbsorptionFix;
|
||||
import nautilus.game.arcade.game.games.uhc.components.UHCBorder;
|
||||
import nautilus.game.arcade.game.games.uhc.components.UHCFreezer;
|
||||
import nautilus.game.arcade.game.games.uhc.components.UHCSpeedMode;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.CollectFoodStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.HalfHeartHealStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.HoeCraftingStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.LuckyMinerStat;
|
||||
import nautilus.game.arcade.game.games.uhc.stat.PackMasterStat;
|
||||
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
|
||||
import nautilus.game.arcade.game.modules.OreVeinEditorModule;
|
||||
import nautilus.game.arcade.game.modules.PlayerHeadModule;
|
||||
@ -181,6 +185,7 @@ public abstract class UHC extends Game
|
||||
registerChatStats(Kills, Assists, BlankLine, DamageTaken, DamageDealt);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UHC(ArcadeManager manager, GameType type, boolean speedMode)
|
||||
{
|
||||
super(manager, type, new Kit[] { new KitUHC(manager) },
|
||||
@ -276,6 +281,8 @@ public abstract class UHC extends Game
|
||||
new AntiExpOrbModule().register(this);
|
||||
new RejoinModule().register(this);
|
||||
new AbsorptionFix(this);
|
||||
|
||||
registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this), new PackMasterStat(this));
|
||||
|
||||
registerDebugCommand(new DebugCommand("startpvp", Rank.ADMIN)
|
||||
{
|
||||
@ -972,10 +979,7 @@ public abstract class UHC extends Game
|
||||
|
||||
Location location = npc.getNPC().getLocation();
|
||||
|
||||
for (ItemStack item : npc.getPlayerInfo().getItems())
|
||||
{
|
||||
location.getWorld().dropItemNaturally(location, item);
|
||||
}
|
||||
placeItemsInChest(npc.getPlayerInfo().getItems(), location);
|
||||
|
||||
getModule(RejoinModule.class).stopPlayerFromRejoining(npc.getPlayerInfo().getName());
|
||||
}
|
||||
@ -1300,6 +1304,24 @@ public abstract class UHC extends Game
|
||||
return targetBlock.getLocation().add(0.5, 0.5, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
public void placeItemsInChest(Collection<ItemStack> drops, Location location)
|
||||
{
|
||||
// Place their items in a chest
|
||||
Block block = location.getBlock();
|
||||
|
||||
block.setType(Material.CHEST);
|
||||
block.getRelative(BlockFace.NORTH).setType(Material.CHEST);
|
||||
|
||||
Chest chest = (Chest) block.getState();
|
||||
Inventory inventory = chest.getInventory();
|
||||
int i = 0;
|
||||
|
||||
for (ItemStack itemStack : drops)
|
||||
{
|
||||
inventory.setItem(i++, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void GhastDrops(EntityDeathEvent event)
|
||||
@ -1331,20 +1353,7 @@ public abstract class UHC extends Game
|
||||
long timeAlive = System.currentTimeMillis() - GetStateTime();
|
||||
AddGems(player, timeAlive / 60000d, "Survived " + UtilTime.MakeStr(timeAlive), false, false);
|
||||
|
||||
// Place their items in a chest
|
||||
Block block = player.getLocation().getBlock();
|
||||
|
||||
block.setType(Material.CHEST);
|
||||
block.getRelative(BlockFace.NORTH).setType(Material.CHEST);
|
||||
|
||||
Chest chest = (Chest) block.getState();
|
||||
Inventory inventory = chest.getInventory();
|
||||
int i = 0;
|
||||
|
||||
for (ItemStack itemStack : event.getDrops())
|
||||
{
|
||||
inventory.setItem(i++, itemStack);
|
||||
}
|
||||
placeItemsInChest(event.getDrops(), loc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1692,6 +1701,30 @@ public abstract class UHC extends Game
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
public void addUHCAchievement(Player player, String achievement)
|
||||
{
|
||||
if (!Manager.IsRewardStats())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Integer> stats = GetStats().get(player);
|
||||
String gameType = null;
|
||||
|
||||
if (isSpeedMode())
|
||||
{
|
||||
gameType = "Ultra Hardcore Speed";
|
||||
}
|
||||
else
|
||||
{
|
||||
gameType = "Ultra Hardcore";
|
||||
}
|
||||
|
||||
stats.put(gameType + "." + achievement, 1);
|
||||
|
||||
Bukkit.broadcastMessage("Adding achievement " + gameType + "." + achievement + " for " + player.getName());
|
||||
}
|
||||
|
||||
public UHCBorder getBorder()
|
||||
{
|
||||
|
@ -0,0 +1,66 @@
|
||||
package nautilus.game.arcade.game.games.uhc.stat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
public class CollectFoodStat extends StatTracker<UHC>
|
||||
{
|
||||
|
||||
private static final Set<Material> FOOD_TO_EAT;
|
||||
|
||||
private Map<UUID, Set<Material>> _eaten = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
FOOD_TO_EAT = Sets.newHashSet(Material.COOKED_BEEF, Material.COOKED_CHICKEN, Material.COOKED_FISH, Material.COOKED_MUTTON, Material.COOKED_RABBIT);
|
||||
}
|
||||
|
||||
public CollectFoodStat(UHC game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerItemConsume(PlayerItemConsumeEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Material material = event.getItem().getType();
|
||||
|
||||
if (FOOD_TO_EAT.contains(material))
|
||||
{
|
||||
Set<Material> eaten = _eaten.get(player.getUniqueId());
|
||||
|
||||
if (eaten == null)
|
||||
{
|
||||
eaten = new HashSet<>();
|
||||
_eaten.put(player.getUniqueId(), eaten);
|
||||
}
|
||||
|
||||
if (!eaten.contains(material))
|
||||
{
|
||||
Bukkit.broadcastMessage("Eaten " + material.toString());
|
||||
eaten.add(material);
|
||||
}
|
||||
|
||||
if (eaten.size() == FOOD_TO_EAT.size())
|
||||
{
|
||||
getGame().addUHCAchievement(player, "Food");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package nautilus.game.arcade.game.games.uhc.stat;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
public class HalfHeartHealStat extends StatTracker<UHC>
|
||||
{
|
||||
|
||||
private Set<UUID> _players = new HashSet<>();
|
||||
|
||||
public HalfHeartHealStat(UHC game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getGame().GetPlayers(true))
|
||||
{
|
||||
if (player.getHealth() < 2 && !_players.contains(player.getUniqueId()))
|
||||
{
|
||||
Bukkit.broadcastMessage("Added");
|
||||
_players.add(player.getUniqueId());
|
||||
}
|
||||
else if (player.getHealth() >= 20 && _players.contains(player.getUniqueId()))
|
||||
{
|
||||
getGame().addUHCAchievement(player, "Die");
|
||||
_players.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package nautilus.game.arcade.game.games.uhc.stat;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
public class HoeCraftingStat extends StatTracker<UHC>
|
||||
{
|
||||
|
||||
public HoeCraftingStat(UHC game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void craft(CraftItemEvent event)
|
||||
{
|
||||
if (event.getCurrentItem().getType() == Material.DIAMOND_HOE)
|
||||
{
|
||||
getGame().addUHCAchievement((Player) event.getWhoClicked(), "Hoe");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package nautilus.game.arcade.game.games.uhc.stat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
public class LuckyMinerStat extends StatTracker<UHC>
|
||||
{
|
||||
|
||||
private static final long BEFORE_TIME = TimeUnit.MINUTES.toMillis(10);
|
||||
|
||||
public LuckyMinerStat(UHC game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC_05 || UtilTime.elapsed(getGame().GetStateTime(), BEFORE_TIME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
playerLoop : for (Player player : getGame().GetPlayers(true))
|
||||
{
|
||||
for (ItemStack itemStack : player.getInventory().getArmorContents())
|
||||
{
|
||||
if (!UtilItem.isIronProduct(itemStack))
|
||||
{
|
||||
continue playerLoop;
|
||||
}
|
||||
}
|
||||
|
||||
getGame().addUHCAchievement(player, "Miner");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package nautilus.game.arcade.game.games.uhc.stat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
public class PackMasterStat extends StatTracker<UHC>
|
||||
{
|
||||
|
||||
private static final int WOLFS_TO_TAME = 4;
|
||||
|
||||
private Map<UUID, Integer> _wolfs = new HashMap<>();
|
||||
|
||||
public PackMasterStat(UHC game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (event.getRightClicked().getType() == EntityType.WOLF)
|
||||
{
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityTame(EntityTameEvent event)
|
||||
{
|
||||
if (event.getEntityType() != EntityType.WOLF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage(event.getOwner().getUniqueId().toString());
|
||||
Bukkit.broadcastMessage(event.getOwner().getName());
|
||||
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if (!_wolfs.containsKey(player.getUniqueId()))
|
||||
{
|
||||
_wolfs.put(player.getUniqueId(), 0);
|
||||
}
|
||||
|
||||
_wolfs.put(player.getUniqueId(), _wolfs.get(player.getUniqueId()) + 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCombatDeath(CombatDeathEvent event)
|
||||
{
|
||||
CombatComponent killer = event.GetLog().GetKiller();
|
||||
|
||||
if (killer.IsPlayer())
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(killer.getUniqueIdOfEntity());
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int wolfs = _wolfs.get(player.getUniqueId());
|
||||
|
||||
if (wolfs >= WOLFS_TO_TAME)
|
||||
{
|
||||
getGame().addUHCAchievement(player, "WolfTame");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user