Make Kit Progression award XP on all kits used in a game
This commit is contained in:
parent
e57ab4bf3d
commit
722c858491
@ -351,6 +351,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
public int PlayersPerTeam = 2;
|
public int PlayersPerTeam = 2;
|
||||||
public int TeamCount = 0;
|
public int TeamCount = 0;
|
||||||
|
|
||||||
|
// Split Kit XP
|
||||||
|
public boolean SplitKitXP = false;
|
||||||
|
|
||||||
private IPacketHandler _useEntityPacketHandler;
|
private IPacketHandler _useEntityPacketHandler;
|
||||||
private int _deadBodyCount;
|
private int _deadBodyCount;
|
||||||
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
|
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
|
||||||
@ -813,8 +816,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
}
|
}
|
||||||
UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin());
|
UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin());
|
||||||
|
|
||||||
System.out.println("Kit instance of " + String.valueOf(kit instanceof ProgressingKit));
|
|
||||||
|
|
||||||
if (kit instanceof ProgressingKit)
|
if (kit instanceof ProgressingKit)
|
||||||
{
|
{
|
||||||
ProgressingKit progressingKit = (ProgressingKit) kit;
|
ProgressingKit progressingKit = (ProgressingKit) kit;
|
||||||
|
@ -137,6 +137,7 @@ public class CastleSiegeNew extends TeamGame
|
|||||||
BlockBreakAllow.add(Material.FENCE.getId());
|
BlockBreakAllow.add(Material.FENCE.getId());
|
||||||
BlockPlaceAllow.add(Material.FENCE.getId());
|
BlockPlaceAllow.add(Material.FENCE.getId());
|
||||||
InventoryClick = true;
|
InventoryClick = true;
|
||||||
|
SplitKitXP = true;
|
||||||
|
|
||||||
manager.GetCreature().SetDisableCustomDrops(true);
|
manager.GetCreature().SetDisableCustomDrops(true);
|
||||||
|
|
||||||
|
@ -59,24 +59,6 @@ public class CastleSiegeTNTManager implements Listener
|
|||||||
private static final int TNT_WEAKNESS_DISTANCE_SQUARED = 16;
|
private static final int TNT_WEAKNESS_DISTANCE_SQUARED = 16;
|
||||||
private static final long TNT_MAX_TIME = TimeUnit.SECONDS.toMillis(30);
|
private static final long TNT_MAX_TIME = TimeUnit.SECONDS.toMillis(30);
|
||||||
private static final long REGENERATION_TIME = TimeUnit.SECONDS.toMillis(15);
|
private static final long REGENERATION_TIME = TimeUnit.SECONDS.toMillis(15);
|
||||||
private static final List<Material> 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;
|
private final CastleSiegeNew _host;
|
||||||
|
|
||||||
@ -309,7 +291,14 @@ public class CastleSiegeTNTManager implements Listener
|
|||||||
|
|
||||||
for (Block block : event.blockList())
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public class KitHumanPaladin extends KitCastleSiege
|
|||||||
|
|
||||||
public KitHumanPaladin(ArcadeManager manager)
|
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());
|
setAchievementRequirements(CastleSiegeNew.getGameAchievements());
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.C;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.disguise.disguises.DisguiseSkeleton;
|
import mineplex.core.disguise.disguises.DisguiseSkeleton;
|
||||||
@ -25,7 +23,7 @@ public class KitUndeadSummoner extends KitCastleSiege
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static final String[] DESCRIPTION = {
|
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")
|
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(
|
private static final MobPotion SILVER_FISH = new MobPotion(
|
||||||
new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME))
|
new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME))
|
||||||
.setTitle(C.cGreen + "Slime Potion")
|
.setTitle(C.cGreen + "Slime Egg")
|
||||||
.build(), EntityType.SLIME, 3);
|
.build(), EntityType.SLIME, 3);
|
||||||
private static final MobPotion ZOMBIE = new MobPotion(
|
private static final MobPotion ZOMBIE = new MobPotion(
|
||||||
new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.ZOMBIE))
|
new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.ZOMBIE))
|
||||||
.setTitle(C.cGreen + "Zombie Potion")
|
.setTitle(C.cGreen + "Zombie Egg")
|
||||||
.build(), EntityType.ZOMBIE, 1);
|
.build(), EntityType.ZOMBIE, 1);
|
||||||
private static final MobPotion SPIDER = new MobPotion(
|
private static final MobPotion SPIDER = new MobPotion(
|
||||||
new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SPIDER))
|
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)
|
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());
|
setAchievementRequirements(CastleSiegeNew.getGameAchievements());
|
||||||
_witherSkeleton = true;
|
_witherSkeleton = true;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package nautilus.game.arcade.game.games.castlesiegenew.perks;
|
package nautilus.game.arcade.game.games.castlesiegenew.perks;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -11,17 +9,16 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Slime;
|
import org.bukkit.entity.Slime;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
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.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.recharge.Recharge;
|
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 static final PotionEffect SPEED = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false);
|
||||||
|
|
||||||
private final MobPotion[] _mobPotions;
|
private final MobPotion[] _mobPotions;
|
||||||
private final Map<ThrownPotion, Pair<Player, MobPotion>> _thrownPotions = new HashMap<>();
|
|
||||||
private final Set<SummonedEntity> _entities = new HashSet<>();
|
private final Set<SummonedEntity> _entities = new HashSet<>();
|
||||||
private final long _cooldown;
|
private final long _cooldown;
|
||||||
|
|
||||||
@ -101,33 +97,11 @@ public class PerkMobPotions extends Perk
|
|||||||
Manager.GetGame().CreatureAllowOverride = true;
|
Manager.GetGame().CreatureAllowOverride = true;
|
||||||
|
|
||||||
Location location = player.getEyeLocation();
|
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));
|
for (int i = 0; i < clickedPotion.getAmount(); i++)
|
||||||
|
|
||||||
Manager.GetGame().CreatureAllowOverride = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void splash(PotionSplashEvent event)
|
|
||||||
{
|
{
|
||||||
ThrownPotion potion = event.getEntity();
|
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)));
|
||||||
if (!_thrownPotions.containsKey(potion))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pair<Player, MobPotion> 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());
|
|
||||||
entity.addPotionEffect(SPEED);
|
entity.addPotionEffect(SPEED);
|
||||||
entity.setCustomName(player.getName() + "'s Minion");
|
entity.setCustomName(player.getName() + "'s Minion");
|
||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
|
@ -63,7 +63,6 @@ public class Evolution extends SoloGame
|
|||||||
|
|
||||||
private ArrayList<EvoKit> _mobKits = new ArrayList<EvoKit>();
|
private ArrayList<EvoKit> _mobKits = new ArrayList<EvoKit>();
|
||||||
private ArrayList<Kit> _kits = new ArrayList<Kit>();
|
private ArrayList<Kit> _kits = new ArrayList<Kit>();
|
||||||
private Map<UUID, ProgressingKit> _startedKit = Maps.newHashMap();
|
|
||||||
|
|
||||||
private NautHashMap<String, EvoToken> _tokens = new NautHashMap<String, EvoToken>();
|
private NautHashMap<String, EvoToken> _tokens = new NautHashMap<String, EvoToken>();
|
||||||
|
|
||||||
@ -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()
|
public EvolveManager getEvolve()
|
||||||
{
|
{
|
||||||
return _evolve;
|
return _evolve;
|
||||||
|
@ -8,20 +8,21 @@ import nautilus.game.arcade.game.Game;
|
|||||||
public class KitProgressionData
|
public class KitProgressionData
|
||||||
{
|
{
|
||||||
|
|
||||||
private ProgressingKit _kit;
|
private final ProgressingKit _kit;
|
||||||
private Game _game;
|
private final Game _game;
|
||||||
private int _xpGained;
|
private final long _selectTime;
|
||||||
|
private long _endTime;
|
||||||
|
|
||||||
public KitProgressionData(ProgressingKit kit, Game game, int xpGained)
|
public KitProgressionData(ProgressingKit kit, Game game)
|
||||||
{
|
{
|
||||||
_kit = kit;
|
_kit = kit;
|
||||||
_game = game;
|
_game = game;
|
||||||
_xpGained = xpGained;
|
_selectTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getXpGained()
|
public ProgressingKit getKit()
|
||||||
{
|
{
|
||||||
return _xpGained;
|
return _kit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game getGame()
|
public Game getGame()
|
||||||
@ -29,8 +30,18 @@ public class KitProgressionData
|
|||||||
return _game;
|
return _game;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressingKit getKit()
|
public long getSelectTime()
|
||||||
{
|
{
|
||||||
return _kit;
|
return _selectTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime()
|
||||||
|
{
|
||||||
|
_endTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEndTime()
|
||||||
|
{
|
||||||
|
return _endTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,29 @@
|
|||||||
package nautilus.game.arcade.kit;
|
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.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
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.confirmation.ConfirmationPage;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
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 nautilus.game.arcade.ArcadeManager;
|
||||||
import java.util.Map;
|
import nautilus.game.arcade.shop.KitPackage;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kit wrapper for all new kits
|
* Kit wrapper for all new kits
|
||||||
@ -232,11 +234,6 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
|
|||||||
@Override
|
@Override
|
||||||
public void onSelected(UUID player)
|
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());
|
_dataManager.get(player).setCurrentKit(getInternalName());
|
||||||
Manager.GetGame().SetKit(Bukkit.getPlayer(player), this, true);
|
Manager.GetGame().SetKit(Bukkit.getPlayer(player), this, true);
|
||||||
Manager.getProgressionKitManager().displayParticles(this, player);
|
Manager.getProgressionKitManager().displayParticles(this, player);
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package nautilus.game.arcade.managers;
|
package nautilus.game.arcade.managers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -9,15 +12,12 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import mineplex.core.common.Rank;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -30,6 +30,8 @@ import nautilus.game.arcade.ArcadeFormat;
|
|||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.events.PlayerKitApplyEvent;
|
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;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
import nautilus.game.arcade.kit.ChampionsKit;
|
import nautilus.game.arcade.kit.ChampionsKit;
|
||||||
@ -43,19 +45,64 @@ import nautilus.game.arcade.kit.ProgressingKit;
|
|||||||
public class ProgressingKitManager implements Listener
|
public class ProgressingKitManager implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
private ArcadeManager _manager;
|
private final ArcadeManager _manager;
|
||||||
private Map<UUID, KitProgressionData> _data;
|
private final Map<UUID, List<KitProgressionData>> _data;
|
||||||
private final Map<UUID, BukkitTask> _tasks = Maps.newHashMap();
|
private final Map<UUID, Integer> _xpGained;
|
||||||
|
private final Map<UUID, BukkitTask> _tasks;
|
||||||
|
|
||||||
private static final String LINE = ArcadeFormat.Line;
|
private static final String LINE = ArcadeFormat.Line;
|
||||||
private static final String INFO = C.cWhiteB + "Kit Progression Progress";
|
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 = " ";
|
private static final String SPACE = " ";
|
||||||
|
|
||||||
public ProgressingKitManager(ArcadeManager manager)
|
public ProgressingKitManager(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
_manager.getPlugin().getServer().getPluginManager().registerEvents(this, _manager.getPlugin());
|
UtilServer.RegisterEvents(this);
|
||||||
_data = Maps.newHashMap();
|
_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 + " <level>"));
|
||||||
|
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)
|
public void displayParticles(ProgressingKit kit, UUID player)
|
||||||
@ -100,7 +147,7 @@ public class ProgressingKitManager implements Listener
|
|||||||
public void entityClick(Player player, Kit kit)
|
public void entityClick(Player player, Kit kit)
|
||||||
{
|
{
|
||||||
PlayerKitApplyEvent kitEvent = new PlayerKitApplyEvent(_manager.GetGame(), kit, player);
|
PlayerKitApplyEvent kitEvent = new PlayerKitApplyEvent(_manager.GetGame(), kit, player);
|
||||||
UtilServer.getServer().getPluginManager().callEvent(kitEvent);
|
UtilServer.CallEvent(kitEvent);
|
||||||
if (kitEvent.isCancelled())
|
if (kitEvent.isCancelled())
|
||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main("Game", kitEvent.getCancelMessage()));
|
UtilPlayer.message(player, F.main("Game", kitEvent.getCancelMessage()));
|
||||||
@ -115,6 +162,7 @@ public class ProgressingKitManager implements Listener
|
|||||||
{
|
{
|
||||||
//Odd, someone else is using a kit system.
|
//Odd, someone else is using a kit system.
|
||||||
//Shouldn't ever happen, but we'll be careful.
|
//Shouldn't ever happen, but we'll be careful.
|
||||||
|
// Work Tim you really are big headed.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!((ProgressingKit) kit).canEquipKit(player))
|
if (!((ProgressingKit) kit).canEquipKit(player))
|
||||||
@ -152,6 +200,8 @@ public class ProgressingKitManager implements Listener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event)
|
public void onQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
|
UUID key = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Fail safe updating in case a player leaves the game before we do data
|
//Fail safe updating in case a player leaves the game before we do data
|
||||||
@ -179,47 +229,57 @@ public class ProgressingKitManager implements Listener
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_data.remove(event.getPlayer().getUniqueId());
|
_data.remove(key);
|
||||||
}
|
_xpGained.remove(key);
|
||||||
}
|
|
||||||
|
|
||||||
@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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void cancelParticles(GameStateChangeEvent event)
|
public void cancelParticles(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
if(event.GetState() == GameState.Prepare)
|
if (event.GetState() != GameState.Prepare)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.GetGame().GetPlayers(true).forEach(this::cancelParticles);
|
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<KitProgressionData> 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
|
@EventHandler
|
||||||
public void onChange(GameStateChangeEvent event)
|
public void onChange(GameStateChangeEvent event)
|
||||||
@ -237,7 +297,7 @@ public class ProgressingKitManager implements Listener
|
|||||||
|
|
||||||
private void resetDefaultKits()
|
private void resetDefaultKits()
|
||||||
{
|
{
|
||||||
Lists.newArrayList(UtilServer.getPlayers()).forEach(player ->
|
UtilServer.getPlayersCollection().forEach(player ->
|
||||||
{
|
{
|
||||||
for (Kit kit : _manager.GetGame().GetKits())
|
for (Kit kit : _manager.GetGame().GetKits())
|
||||||
{
|
{
|
||||||
@ -257,24 +317,45 @@ public class ProgressingKitManager implements Listener
|
|||||||
|
|
||||||
public void displayKitData(Player player)
|
public void displayKitData(Player player)
|
||||||
{
|
{
|
||||||
KitProgressionData data = _data.remove(player.getUniqueId());
|
UUID key = player.getUniqueId();
|
||||||
|
List<KitProgressionData> dataList = _data.remove(key);
|
||||||
|
Integer xpGained = _xpGained.remove(key);
|
||||||
|
|
||||||
if (data == null)
|
if (dataList == null || xpGained == null)
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!data.getKit().usesXp())
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KitProgressionData latestData = dataList.get(dataList.size() - 1);
|
||||||
|
latestData.setEndTime();
|
||||||
|
long totalTime = latestData.getEndTime() - dataList.get(0).getSelectTime();
|
||||||
|
|
||||||
player.sendMessage(SPACE);
|
player.sendMessage(SPACE);
|
||||||
|
|
||||||
player.sendMessage(LINE);
|
player.sendMessage(LINE);
|
||||||
player.sendMessage(INFO);
|
player.sendMessage(INFO);
|
||||||
player.sendMessage(SPACE);
|
player.sendMessage(SPACE);
|
||||||
|
|
||||||
int xpGained = data.getXpGained();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
ProgressingKit kit = data.getKit();
|
ProgressingKit kit = data.getKit();
|
||||||
|
|
||||||
PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId());
|
PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId());
|
||||||
@ -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(C.cWhite + "You maxed out this kit! Great job, and thanks for playing on Mineplex!");
|
||||||
|
|
||||||
player.sendMessage(SPACE);
|
player.sendMessage(SPACE);
|
||||||
player.sendMessage(LINE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +382,6 @@ public class ProgressingKitManager implements Listener
|
|||||||
xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()));
|
xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId());
|
kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId());
|
||||||
boolean leveledUp = false;
|
boolean leveledUp = false;
|
||||||
|
|
||||||
@ -348,34 +427,36 @@ public class ProgressingKitManager implements Listener
|
|||||||
//The XP required to level up
|
//The XP required to level up
|
||||||
builder.append(C.cYellow)
|
builder.append(C.cYellow)
|
||||||
.append(difference)
|
.append(difference)
|
||||||
.append(" to next level");
|
.append(" to Next Level");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
builder.append(C.cAquaB)
|
builder.append(C.cAquaB)
|
||||||
.append("LEVEL UP! ")
|
.append("LEVEL UP! ")
|
||||||
.append(C.cYellow)
|
.append(C.cYellow)
|
||||||
.append(Calculations.getXpForNextLevel(currentLevel))
|
.append(Calculations.getXpForNextLevel(currentLevel))
|
||||||
.append(" to next level");
|
.append(" to Next Level");
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send the message finally
|
//Send the message finally
|
||||||
player.sendMessage(builder.toString());
|
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()
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package nautilus.game.arcade.stats;
|
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 mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game;
|
import nautilus.game.arcade.game.Game;
|
||||||
import nautilus.game.arcade.game.GemData;
|
import nautilus.game.arcade.game.GemData;
|
||||||
import nautilus.game.arcade.game.games.evolution.Evolution;
|
import nautilus.game.arcade.game.games.evolution.Evolution;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
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<Game>
|
public class ExperienceStatTracker extends StatTracker<Game>
|
||||||
{
|
{
|
||||||
@ -98,18 +99,8 @@ public class ExperienceStatTracker extends StatTracker<Game>
|
|||||||
|
|
||||||
//Exp
|
//Exp
|
||||||
int expGained = (int)(((timeExp + gemExp)*mult)*getGame().XpMult);
|
int expGained = (int)(((timeExp + gemExp)*mult)*getGame().XpMult);
|
||||||
//Exp
|
// Kit Exp
|
||||||
Kit kit = event.GetGame().GetKit(player);
|
event.GetGame().getArcadeManager().getProgressionKitManager().setXPEarned(player, expGained);
|
||||||
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);
|
|
||||||
}
|
|
||||||
//Record Global and per Game
|
//Record Global and per Game
|
||||||
addStat(player, "ExpEarned", expGained, false, true);
|
addStat(player, "ExpEarned", expGained, false, true);
|
||||||
addStat(player, "ExpEarned", expGained, false, false);
|
addStat(player, "ExpEarned", expGained, false, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user