diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 46c6dd349..b2365f8cd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -351,6 +351,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed public int PlayersPerTeam = 2; public int TeamCount = 0; + // Split Kit XP + public boolean SplitKitXP = false; + private IPacketHandler _useEntityPacketHandler; private int _deadBodyCount; private NautHashMap _deadBodies = new NautHashMap(); @@ -813,8 +816,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed } UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin()); - System.out.println("Kit instance of " + String.valueOf(kit instanceof ProgressingKit)); - if (kit instanceof ProgressingKit) { ProgressingKit progressingKit = (ProgressingKit) kit; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java index 1e2f66abf..1ffbc2e3a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java @@ -137,6 +137,7 @@ public class CastleSiegeNew extends TeamGame BlockBreakAllow.add(Material.FENCE.getId()); BlockPlaceAllow.add(Material.FENCE.getId()); InventoryClick = true; + SplitKitXP = true; manager.GetCreature().SetDisableCustomDrops(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java index 78175aa27..10c8c2185 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java @@ -59,24 +59,6 @@ public class CastleSiegeTNTManager implements Listener private static final int TNT_WEAKNESS_DISTANCE_SQUARED = 16; private static final long TNT_MAX_TIME = TimeUnit.SECONDS.toMillis(30); private static final long REGENERATION_TIME = TimeUnit.SECONDS.toMillis(15); - private static final List REGENERATE_BLOCKS = Arrays.asList( - Material.GRASS, - Material.DIRT, - Material.STONE, - Material.COBBLESTONE, - Material.MOSSY_COBBLESTONE, - Material.GRAVEL, - Material.SAND, - Material.LOG, - Material.LOG_2, - Material.LEAVES, - Material.LEAVES_2, - Material.WATER, - Material.STATIONARY_WATER, - Material.LADDER, - Material.SNOW, - Material.SNOW_BLOCK - ); private final CastleSiegeNew _host; @@ -309,7 +291,14 @@ public class CastleSiegeTNTManager implements Listener for (Block block : event.blockList()) { - if (!REGENERATE_BLOCKS.contains(block.getType())) + Material material = block.getType(); + byte materialData = block.getData(); + + if ( + material == Material.SMOOTH_BRICK && materialData == 2 || + material == Material.IRON_FENCE || + material == Material.FENCE + ) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java index 96306832b..003d32316 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java @@ -133,7 +133,7 @@ public class KitHumanPaladin extends KitCastleSiege public KitHumanPaladin(ArcadeManager manager) { - super(manager, "Castle Paladin", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND); + super(manager, "Castle Paladin", KitAvailability.Achievement, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND); setAchievementRequirements(CastleSiegeNew.getGameAchievements()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java index 14713b155..7a00040fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java @@ -7,8 +7,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.achievement.Achievement; -import mineplex.core.achievement.AchievementCategory; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; import mineplex.core.disguise.disguises.DisguiseSkeleton; @@ -25,7 +23,7 @@ public class KitUndeadSummoner extends KitCastleSiege { private static final String[] DESCRIPTION = { - "I hope I’m not bugging you.", + "Say hello to my little friend.", "", click(false, "your eggs to spawn undead mobs to help you fight") }; @@ -34,11 +32,11 @@ public class KitUndeadSummoner extends KitCastleSiege private static final MobPotion SILVER_FISH = new MobPotion( new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME)) - .setTitle(C.cGreen + "Slime Potion") + .setTitle(C.cGreen + "Slime Egg") .build(), EntityType.SLIME, 3); private static final MobPotion ZOMBIE = new MobPotion( new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.ZOMBIE)) - .setTitle(C.cGreen + "Zombie Potion") + .setTitle(C.cGreen + "Zombie Egg") .build(), EntityType.ZOMBIE, 1); private static final MobPotion SPIDER = new MobPotion( new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SPIDER)) @@ -84,11 +82,11 @@ public class KitUndeadSummoner extends KitCastleSiege } }; - private static final ItemStack IN_HAND = new ItemStack(Material.MONSTER_EGG); + private static final ItemStack IN_HAND = new ItemStack(Material.BONE); public KitUndeadSummoner(ArcadeManager manager) { - super(manager, "Undead Summoner", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND); + super(manager, "Undead Summoner", KitAvailability.Achievement, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND); setAchievementRequirements(CastleSiegeNew.getGameAchievements()); _witherSkeleton = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java index f6333eb9c..b5a3aee33 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java @@ -1,8 +1,6 @@ package nautilus.game.arcade.game.games.castlesiegenew.perks; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -11,17 +9,16 @@ import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; -import org.bukkit.entity.ThrownPotion; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; -import mineplex.core.common.Pair; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; @@ -42,7 +39,6 @@ public class PerkMobPotions extends Perk private static final PotionEffect SPEED = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false); private final MobPotion[] _mobPotions; - private final Map> _thrownPotions = new HashMap<>(); private final Set _entities = new HashSet<>(); private final long _cooldown; @@ -101,33 +97,11 @@ public class PerkMobPotions extends Perk Manager.GetGame().CreatureAllowOverride = true; Location location = player.getEyeLocation(); - ThrownPotion potion = player.getWorld().spawn(location.add(location.getDirection()), ThrownPotion.class); - potion.setVelocity(location.getDirection()); - _thrownPotions.put(potion, Pair.create(player, clickedPotion)); - - Manager.GetGame().CreatureAllowOverride = false; - } - - @EventHandler - public void splash(PotionSplashEvent event) - { - ThrownPotion potion = event.getEntity(); - - if (!_thrownPotions.containsKey(potion)) + for (int i = 0; i < clickedPotion.getAmount(); i++) { - return; - } - - Pair pair = _thrownPotions.remove(potion); - Player player = pair.getLeft(); - MobPotion mobPotion = pair.getRight(); - - Manager.GetGame().CreatureAllowOverride = true; - - for (int i = 0; i < mobPotion.getAmount(); i++) - { - LivingEntity entity = (LivingEntity) potion.getWorld().spawnEntity(potion.getLocation(), mobPotion.getEntityType()); + LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, clickedPotion.getEntityType()); + entity.setVelocity(location.getDirection().add(new Vector(Math.random() - 0.5, 0, Math.random() - 0.5))); entity.addPotionEffect(SPEED); entity.setCustomName(player.getName() + "'s Minion"); entity.setCustomNameVisible(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index fa0e6a7ae..206fd60e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -63,8 +63,7 @@ public class Evolution extends SoloGame private ArrayList _mobKits = new ArrayList(); private ArrayList _kits = new ArrayList(); - private Map _startedKit = Maps.newHashMap(); - + private NautHashMap _tokens = new NautHashMap(); private NautHashMap> _evoPlatforms = new NautHashMap>(); @@ -153,20 +152,6 @@ public class Evolution extends SoloGame ); } - public void select(UUID player, ProgressingKit kit) - { - _startedKit.put(player, kit); - } - - public ProgressingKit getStartedKit(UUID player, boolean remove) - { - if(remove) - { - return _startedKit.remove(player); - } - return _startedKit.get(player); - } - public EvolveManager getEvolve() { return _evolve; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java index ee5caa4e1..40084fc5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java @@ -8,20 +8,21 @@ import nautilus.game.arcade.game.Game; public class KitProgressionData { - private ProgressingKit _kit; - private Game _game; - private int _xpGained; + private final ProgressingKit _kit; + private final Game _game; + private final long _selectTime; + private long _endTime; - public KitProgressionData(ProgressingKit kit, Game game, int xpGained) + public KitProgressionData(ProgressingKit kit, Game game) { _kit = kit; _game = game; - _xpGained = xpGained; + _selectTime = System.currentTimeMillis(); } - public int getXpGained() + public ProgressingKit getKit() { - return _xpGained; + return _kit; } public Game getGame() @@ -29,8 +30,18 @@ public class KitProgressionData return _game; } - public ProgressingKit getKit() + public long getSelectTime() { - return _kit; + return _selectTime; + } + + public void setEndTime() + { + _endTime = System.currentTimeMillis(); + } + + public long getEndTime() + { + return _endTime; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 192523a1a..2c2f12a06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -1,7 +1,29 @@ package nautilus.game.arcade.kit; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import net.minecraft.server.v1_8_R3.EntityFireworks; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; +import net.minecraft.server.v1_8_R3.World; + +import org.bukkit.Bukkit; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.FireworkMeta; + import com.google.common.collect.Lists; import com.google.common.collect.Maps; + import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -17,29 +39,9 @@ import mineplex.core.progression.math.Calculations; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.games.evolution.Evolution; -import nautilus.game.arcade.shop.KitPackage; -import net.minecraft.server.v1_8_R3.EntityFireworks; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; -import net.minecraft.server.v1_8_R3.World; -import org.bukkit.Bukkit; -import org.bukkit.FireworkEffect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Firework; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkMeta; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.shop.KitPackage; /** * Kit wrapper for all new kits @@ -232,11 +234,6 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit @Override public void onSelected(UUID player) { - if(Manager.GetGame().GetType() == GameType.Evolution) - { - Evolution evolution = (Evolution) Manager.GetGame(); - evolution.select(player, this); - } _dataManager.get(player).setCurrentKit(getInternalName()); Manager.GetGame().SetKit(Bukkit.getPlayer(player), this, true); Manager.getProgressionKitManager().displayParticles(this, player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index 35442c7a3..f9fe62812 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -1,5 +1,8 @@ package nautilus.game.arcade.managers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -9,15 +12,12 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -30,6 +30,8 @@ import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerKitApplyEvent; +import nautilus.game.arcade.events.PlayerKitGiveEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.ChampionsKit; @@ -43,24 +45,69 @@ import nautilus.game.arcade.kit.ProgressingKit; public class ProgressingKitManager implements Listener { - private ArcadeManager _manager; - private Map _data; - private final Map _tasks = Maps.newHashMap(); + private final ArcadeManager _manager; + private final Map> _data; + private final Map _xpGained; + private final Map _tasks; private static final String LINE = ArcadeFormat.Line; private static final String INFO = C.cWhiteB + "Kit Progression Progress"; + private static final String LEVEL_INFO = "Level up a kit by playing with it."; private static final String SPACE = " "; public ProgressingKitManager(ArcadeManager manager) { _manager = manager; - _manager.getPlugin().getServer().getPluginManager().registerEvents(this, _manager.getPlugin()); - _data = Maps.newHashMap(); + UtilServer.RegisterEvents(this); + _data = new HashMap<>(); + _xpGained = new HashMap<>(); + _tasks = new HashMap<>(); + + manager.addCommand(new DebugCommand("kpsetlevel", Rank.ADMIN) + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length == 0) + { + caller.sendMessage(F.main("Kit", "/" + _aliasUsed + " ")); + return; + } + + Kit kit = manager.GetGame().GetKit(caller); + + if (kit == null || !(kit instanceof ProgressingKit)) + { + return; + } + + int level; + + try + { + level = Integer.parseInt(args[0]); + } + catch (NumberFormatException e) + { + caller.sendMessage(F.main("Kit", "That is not a number.")); + return; + } + + if (level < 0 || level > 5) + { + caller.sendMessage(F.main("Kit", "Please enter a number between 0 and 5.")); + return; + } + + caller.sendMessage(F.main("Kit", "Set the upgrade level for " + F.name(kit.GetName()) + " to " + F.elem(level) + ".")); + ((ProgressingKit) kit).setUpgradeLevel(level, caller.getUniqueId()); + } + }); } public void displayParticles(ProgressingKit kit, UUID player) { - if(_tasks.containsKey(player)) + if (_tasks.containsKey(player)) { //He has one selected _tasks.remove(player).cancel(); @@ -71,13 +118,13 @@ public class ProgressingKitManager implements Listener @Override public void run() { - if(kit.getLivingEntity() == null) + if (kit.getLivingEntity() == null) { cancel(); _tasks.remove(player); return; } - if(Bukkit.getPlayer(player) == null) + if (Bukkit.getPlayer(player) == null) { cancel(); _tasks.remove(player); @@ -100,7 +147,7 @@ public class ProgressingKitManager implements Listener public void entityClick(Player player, Kit kit) { PlayerKitApplyEvent kitEvent = new PlayerKitApplyEvent(_manager.GetGame(), kit, player); - UtilServer.getServer().getPluginManager().callEvent(kitEvent); + UtilServer.CallEvent(kitEvent); if (kitEvent.isCancelled()) { UtilPlayer.message(player, F.main("Game", kitEvent.getCancelMessage())); @@ -115,9 +162,10 @@ public class ProgressingKitManager implements Listener { //Odd, someone else is using a kit system. //Shouldn't ever happen, but we'll be careful. + // Work Tim you really are big headed. return; } - if(!((ProgressingKit) kit).canEquipKit(player)) + if (!((ProgressingKit) kit).canEquipKit(player)) { return; } @@ -152,6 +200,8 @@ public class ProgressingKitManager implements Listener @EventHandler public void onQuit(PlayerQuitEvent event) { + UUID key = event.getPlayer().getUniqueId(); + try { //Fail safe updating in case a player leaves the game before we do data @@ -179,47 +229,57 @@ public class ProgressingKitManager implements Listener } finally { - _data.remove(event.getPlayer().getUniqueId()); - } - } - - @EventHandler - public void testCommand(PlayerCommandPreprocessEvent event) - { - //This needs to stay in for testing sakes if the issue arises connor - String message = event.getMessage(); - String user = event.getPlayer().getName(); - - if(user.equalsIgnoreCase("Moppletop") || UtilServer.isTestServer()) - { - if(message.startsWith("/kpsetlevel")) - { - event.setCancelled(true); - int level = Integer.parseInt(message.split(" ")[1]); - ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); - kit.setLevel(level, event.getPlayer().getUniqueId()); - event.getPlayer().sendMessage("Set level for "+ kit.GetName() + " to " + level); - } - else if (message.startsWith("/kpclearupgrades")) - { - event.setCancelled(true); - ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); - kit.setUpgradeLevel(0, event.getPlayer().getUniqueId()); - event.getPlayer().sendMessage("Cleared the upgrades for " + kit.GetName()); - } + _data.remove(key); + _xpGained.remove(key); } } @EventHandler public void cancelParticles(GameStateChangeEvent event) { - if(event.GetState() == GameState.Prepare) + if (event.GetState() != GameState.Prepare) { return; } event.GetGame().GetPlayers(true).forEach(this::cancelParticles); } + @EventHandler + public void onKitChange(PlayerKitGiveEvent event) + { + Player player = event.getPlayer(); + Game game = event.getGame(); + Kit kit = event.getKit(); + + if (!game.InProgress() || !(kit instanceof ProgressingKit)) + { + return; + } + + List dataList = _data.get(player.getUniqueId()); + + if (dataList != null) + { + for (KitProgressionData data : dataList) + { + if (data.getKit().equals(kit)) + { + return; + } + else if (data.getEndTime() != 0) + { + continue; + } + + data.setEndTime(); + } + } + + if (game.SplitKitXP || dataList == null) + { + addData(player, game, (ProgressingKit) kit); + } + } @EventHandler public void onChange(GameStateChangeEvent event) @@ -237,7 +297,7 @@ public class ProgressingKitManager implements Listener private void resetDefaultKits() { - Lists.newArrayList(UtilServer.getPlayers()).forEach(player -> + UtilServer.getPlayersCollection().forEach(player -> { for (Kit kit : _manager.GetGame().GetKits()) { @@ -257,29 +317,50 @@ public class ProgressingKitManager implements Listener public void displayKitData(Player player) { - KitProgressionData data = _data.remove(player.getUniqueId()); + UUID key = player.getUniqueId(); + List dataList = _data.remove(key); + Integer xpGained = _xpGained.remove(key); - if (data == null) - { - return; - } - if (!data.getKit().usesXp()) + if (dataList == null || xpGained == null) { return; } + KitProgressionData latestData = dataList.get(dataList.size() - 1); + latestData.setEndTime(); + long totalTime = latestData.getEndTime() - dataList.get(0).getSelectTime(); + player.sendMessage(SPACE); player.sendMessage(LINE); player.sendMessage(INFO); player.sendMessage(SPACE); + + for (KitProgressionData data : dataList) + { + long elapsed = data.getEndTime() - data.getSelectTime(); + int kitXP = (int) (((double) elapsed / (double) totalTime) * xpGained); + + displayKitData(player, data, kitXP); + } + + player.sendMessage(SPACE); + player.sendMessage(LEVEL_INFO); + player.sendMessage(LINE); + } + + private void displayKitData(Player player, KitProgressionData data, int xpGained) + { + if (!data.getKit().usesXp()) + { + return; + } - int xpGained = data.getXpGained(); ProgressingKit kit = data.getKit(); PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); - if(playerKit.getLevel(kit.getInternalName()) >= 100) + if (playerKit.getLevel(kit.getInternalName()) >= 100) { StringBuilder builder = new StringBuilder(); String kitName = C.cGoldB + kit.getDisplayName(); @@ -291,7 +372,6 @@ public class ProgressingKitManager implements Listener player.sendMessage(C.cWhite + "You maxed out this kit! Great job, and thanks for playing on Mineplex!"); player.sendMessage(SPACE); - player.sendMessage(LINE); return; } @@ -302,7 +382,6 @@ public class ProgressingKitManager implements Listener xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())); } - kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId()); boolean leveledUp = false; @@ -323,59 +402,61 @@ public class ProgressingKitManager implements Listener //Name of the kit builder.append(kitName) - .append(" ") - .append(C.Reset); + .append(" ") + .append(C.Reset); //Current level out of 100 builder.append(C.cYellow) - .append(currentLevel) - .append(C.cGold) - .append("/") - .append(C.cYellow) - .append(100) - .append(" ") - .append(C.Reset); + .append(currentLevel) + .append(C.cGold) + .append("/") + .append(C.cYellow) + .append(100) + .append(" ") + .append(C.Reset); //The amount of XP the player gained builder.append(C.cGreen) - .append("+") - .append(xpGained) - .append(" ") - .append(C.Reset); + .append("+") + .append(xpGained) + .append(" ") + .append(C.Reset); if (!leveledUp) { //The XP required to level up builder.append(C.cYellow) - .append(difference) - .append(" to next level"); - } else + .append(difference) + .append(" to Next Level"); + } + else { builder.append(C.cAquaB) - .append("LEVEL UP! ") - .append(C.cYellow) - .append(Calculations.getXpForNextLevel(currentLevel)) - .append(" to next level"); + .append("LEVEL UP! ") + .append(C.cYellow) + .append(Calculations.getXpForNextLevel(currentLevel)) + .append(" to Next Level"); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } //Send the message finally player.sendMessage(builder.toString()); - player.sendMessage(C.cWhite + "Level up by using this kit in game!"); - - player.sendMessage(SPACE); - player.sendMessage(LINE); } public void displayKitData() { - Lists.newArrayList(UtilServer.getPlayers()).forEach(this::displayKitData); + UtilServer.getPlayersCollection().forEach(this::displayKitData); } - public void addData(Player player, int xpGained, Game game, ProgressingKit kit) + private void addData(Player player, Game game, ProgressingKit kit) { - _data.put(player.getUniqueId(), new KitProgressionData(kit, game, xpGained)); + UUID key = player.getUniqueId(); + _data.putIfAbsent(key, new ArrayList<>()); + _data.get(key).add(new KitProgressionData(kit, game)); } + public void setXPEarned(Player player, int xpGained) + { + _xpGained.put(player.getUniqueId(), xpGained); + } } - diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java index 1e4316316..5839592ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java @@ -1,19 +1,20 @@ package nautilus.game.arcade.stats; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerQuitEvent; + import mineplex.core.common.util.NautHashMap; + import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.games.evolution.Evolution; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.ProgressingKit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.List; public class ExperienceStatTracker extends StatTracker { @@ -98,18 +99,8 @@ public class ExperienceStatTracker extends StatTracker //Exp int expGained = (int)(((timeExp + gemExp)*mult)*getGame().XpMult); - //Exp - Kit kit = event.GetGame().GetKit(player); - if(event.GetGame().GetType() == GameType.Evolution) - { - Evolution evolution = (Evolution) event.GetGame(); - kit = evolution.getStartedKit(player.getUniqueId(), true); - } - if (kit instanceof ProgressingKit) - { - ProgressingKit progressingKit = (ProgressingKit) kit; - event.GetGame().Manager.getProgressionKitManager().addData(player, expGained, event.GetGame(), progressingKit); - } + // Kit Exp + event.GetGame().getArcadeManager().getProgressionKitManager().setXPEarned(player, expGained); //Record Global and per Game addStat(player, "ExpEarned", expGained, false, true); addStat(player, "ExpEarned", expGained, false, false);