diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index fb261b841..c980b3d73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -16,9 +16,19 @@ import mineplex.core.stats.StatsManager; public enum AchievementCategory { GLOBAL("Global", null, - new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null, - new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") }, - Material.EMERALD, 0, GameCategory.GLOBAL, "None", false, -1), + new StatDisplay[] + { + StatDisplay.GEMS_EARNED, + new StatDisplay("Exp Earned", "ExpEarned"), + null, + new StatDisplay("Games Played", "GamesPlayed"), + StatDisplay.TIME_IN_GAME, + null, + new StatDisplay("Daily Rewards", "DailyReward"), + new StatDisplay("Times Voted", "DailyVote"), + null, + new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") + }, Material.EMERALD, 0, GameCategory.GLOBAL, "None", false, -1), HOLIDAY("Holiday Achievements", null, new StatDisplay[] {}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 8635324fa..be4e6d334 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilServer; @@ -42,9 +43,6 @@ public class Menu extends ShopPageBase private static final String VISIBILITY_EVERYWHERE = "Visible Everywhere"; private static final String VISIBILITY_GAMES = "Visible in Games"; private static final String VISIBILITY_GAME_HUB = "Visible in Game Lobbies"; - private static final ItemStack PANE = new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) 3) - .setTitle(C.cBlack) - .build(); public Menu(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { @@ -242,11 +240,15 @@ public class Menu extends ShopPageBase } }); + ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) 3) + .setTitle(C.cAqua + _donationManager.Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) + " Shards") + .build(); + for (int i = 0; i < getSize(); i++) { if (getItem(i) == null) { - setItem(i, PANE); + setItem(i, pane); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java index 820ccd155..39765c5aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java @@ -1,13 +1,17 @@ package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.DoubleJumpEffectGadget; @@ -25,7 +29,24 @@ public class DoubleJumpFreedom extends DoubleJumpEffectGadget @Override public void doEffect(Player player) { - UtilFirework.playFreedomFirework(player.getLocation()); + DustSpellColor red = new DustSpellColor(Color.RED), blue = new DustSpellColor(Color.BLUE), white = new DustSpellColor(Color.WHITE); + Location location = player.getLocation().add(0, 1, 0); + + for (int i = 0; i < 5; i++) + { + playParticleAt(location, red); + playParticleAt(location, blue); + playParticleAt(location, white); + } } + private void playParticleAt(Location location, DustSpellColor colour) + { + double x = Math.random() - 0.5, y = Math.random() - 0.5, z = Math.random() - 0.5; + + new ColoredParticle(ParticleType.RED_DUST, colour, location.add(x, y, z)) + .display(); + + location.subtract(x, y, z); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java index e2d644505..46e46d4b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java @@ -1,8 +1,11 @@ package mineplex.core.gadget.gadgets.morph; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -24,6 +27,7 @@ public class MorphOcelot extends MorphGadget super(manager, "Ocelot Morph", new String[] { C.cGray + "Meeeeeeeeeeoooooooowwwwww", + C.cGreen + "Crouch" + C.cWhite + " to meow." }, CostConstants.LEVEL_REWARDS, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.OCELOT)); } @@ -46,4 +50,17 @@ public class MorphOcelot extends MorphGadget UtilMorph.undisguise(player, Manager.getDisguiseManager()); player.removePotionEffect(PotionEffectType.SPEED); } + + @EventHandler(ignoreCancelled = true) + public void playerToggleSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if (!event.isSneaking() || !isActive(player)) + { + return; + } + + player.getWorld().playSound(player.getLocation(), Sound.CAT_MEOW, 1, 1); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java index 5739dcea2..8daeb5dcc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -65,7 +65,9 @@ public enum Preference implements Permission BYPASS_CHAT_FILTER(false, PreferenceCategory.EXCLUSIVE, Material.GLASS, "Bypass Chat Filter", "Enabling this will allow you", "to bypass the chat filter everywhere.", "", "Proceed with caution."), - COLOR_SUFFIXES(true, PreferenceCategory.USER, Material.WOOL, "Color Chat Suffixes", "Enabling this will color your", "chat suffixes like ¯\\_(ツ)_/¯", "based on your rank.") + COLOR_SUFFIXES(true, PreferenceCategory.USER, Material.WOOL, "Color Chat Suffixes", "Enabling this will color your", "chat suffixes like ¯\\_(ツ)_/¯", "based on your rank."), + + PARTICLES_IN_GAME(true, PreferenceCategory.GAME_PLAY, Material.NETHER_STAR, "Display Particles", "Enabling this will show your selected", "particle aura in game.") ; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java index c56d9c874..fb2253fb2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java @@ -9,7 +9,7 @@ public class PreferencesCommand extends CommandBase { public PreferencesCommand(PreferencesManager plugin) { - super(plugin, PreferencesManager.Perm.PREFERENCES_COMMAND, "prefs"); + super(plugin, PreferencesManager.Perm.PREFERENCES_COMMAND, "pref", "prefs"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java index 62124aaee..3c04600ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java @@ -45,7 +45,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; @@ -70,6 +69,7 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.stats.event.PlayerStatsLoadedEvent; import mineplex.core.titles.commands.TrackCommand; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; @@ -155,14 +155,18 @@ public class Titles extends MiniDbClientPlugin implements IPacketHand } @EventHandler - private void onJoin(PlayerJoinEvent event) + private void onJoin(PlayerStatsLoadedEvent event) { - if (Get(event.getPlayer()) != null) + Player player = event.getPlayer(); + TitleData data = Get(player); + + if (data != null) { - Track track = _trackManager.getTrackById(Get(event.getPlayer()).getTrackId()); - if (track != null && track.getRequirements().getTier(event.getPlayer()) != null) + Track track = _trackManager.getTrackById(data.getTrackId()); + + if (track != null && track.getRequirements().getTier(player) != null) { - toggleActiveTrack(event.getPlayer(), track); + toggleActiveTrack(player, track); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index d255fefc2..e37f02424 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -282,7 +282,7 @@ public class ClansUtility public boolean isSafe(Player player) { - if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) return false; + if (!UtilTime.elapsed(_clansManager.getCombatManager().getLog(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) return false; return isSafe(player.getLocation()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 1a7401850..d74dc20db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -1054,9 +1054,9 @@ public class ClansCommand extends CommandBase return; } - if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(caller).GetLastCombatEngaged(), 15000)) + if (!UtilTime.elapsed(_clansManager.getCombatManager().getLog(caller).GetLastCombatEngaged(), 15000)) { - long remain = _clansManager.getCombatManager().Get(caller).GetLastCombatEngaged() + 15000 - System.currentTimeMillis(); + long remain = _clansManager.getCombatManager().getLog(caller).GetLastCombatEngaged() + 15000 - System.currentTimeMillis(); UtilPlayer.message(caller, F.main("Clans", "You are combat tagged for " + F.elem(UtilTime.MakeStr(remain)) + "!")); return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index 47bb1f9b4..2e9012bc0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -20,7 +20,7 @@ public class KillCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) + if (!UtilTime.elapsed(Plugin.getCombatManager().getLog(caller).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index fd8c2554d..f45f18506 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -246,13 +246,13 @@ public class BossNetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + ClansManager.getInstance().getCombatManager().getLog((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + ClansManager.getInstance().getCombatManager().getLog((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 0464d8567..6c9ab28c7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -454,7 +454,7 @@ public class NetherManager extends MiniPlugin OverworldOrigins.remove(event.getPlayer()); event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + ClansManager.getInstance().getCombatManager().getLog(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); }, 1); } @@ -481,7 +481,7 @@ public class NetherManager extends MiniPlugin player.teleport(getReturnLocation(player)); OverworldOrigins.remove(player); player.removePotionEffect(PotionEffectType.NIGHT_VISION); - ClansManager.getInstance().getCombatManager().Get(player).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + ClansManager.getInstance().getCombatManager().getLog(player).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!")); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index daf5ca438..37adbc2e8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -257,13 +257,13 @@ public class NetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + ClansManager.getInstance().getCombatManager().getLog((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + ClansManager.getInstance().getCombatManager().getLog((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java index 92e0a9726..7c1c3c9ef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -44,7 +44,7 @@ public class ForceTeleportCommand extends CommandBase UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); ClansManager.getInstance().runSyncLater(() -> { - ClansManager.getInstance().getCombatManager().Get(caller).SetLastCombatEngaged(System.currentTimeMillis()); + ClansManager.getInstance().getCombatManager().getLog(caller).SetLastCombatEngaged(System.currentTimeMillis()); }, 20); } else diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index c215a3f03..92da88b14 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -191,7 +191,7 @@ public class Spawn extends MiniPlugin { if (isSafe(cur.getLocation())) { - long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombatEngaged(); + long lastDamager = _clansManager.getCombatManager().getLog(cur).GetLastCombatEngaged(); long duration = System.currentTimeMillis() - lastDamager; if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION)) @@ -224,7 +224,7 @@ public class Spawn extends MiniPlugin { if (!isSafe(event.GetPlayer().getLocation())) { - _clansManager.getCombatManager().Get(event.GetPlayer()).SetLastCombatEngaged(System.currentTimeMillis()); + _clansManager.getCombatManager().getLog(event.GetPlayer()).SetLastCombatEngaged(System.currentTimeMillis()); } } @@ -275,7 +275,7 @@ public class Spawn extends MiniPlugin public void onRespawn(PlayerRespawnEvent event) { event.setRespawnLocation(getSpawnLocation()); - _clansManager.getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); + _clansManager.getCombatManager().getLog(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } /* @@ -506,7 +506,7 @@ public class Spawn extends MiniPlugin public boolean isCombatTagged(Player player) { - return !UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION); + return !UtilTime.elapsed(_clansManager.getCombatManager().getLog(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION); } public void teleport(final Player player, final Location location, int delay) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/player/HubPlayerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/player/HubPlayerManager.java index 334372d60..fb9461261 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/player/HubPlayerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/player/HubPlayerManager.java @@ -11,10 +11,14 @@ import org.bukkit.inventory.PlayerInventory; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.achievement.Achievement; +import mineplex.core.achievement.AchievementData; +import mineplex.core.achievement.AchievementManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.stats.event.PlayerStatsLoadedEvent; import mineplex.core.titles.Titles; import mineplex.hub.HubManager; @@ -31,6 +35,7 @@ public class HubPlayerManager extends MiniPlugin .addLore("Click to open the Lobby Selector.") .build(); + private final AchievementManager _achievementManager; private final CosmeticManager _cosmeticManager; private final HubManager _hubManager; private final Titles _titles; @@ -39,6 +44,7 @@ public class HubPlayerManager extends MiniPlugin { super("Hub Player"); + _achievementManager = require(AchievementManager.class); _cosmeticManager = require(CosmeticManager.class); _hubManager = require(HubManager.class); _titles = require(Titles.class); @@ -58,6 +64,18 @@ public class HubPlayerManager extends MiniPlugin giveHotbar(player); } + @EventHandler + public void statsLoad(PlayerStatsLoadedEvent event) + { + Player player = event.getPlayer(); + + AchievementData data = _achievementManager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL); + float levelPercentage = (float) data.getExpRemainder() / data.getExpNextLevel(); + + player.setLevel(data.getLevel()); + player.setExp(Math.min(0, Math.max(0.999F, levelPercentage))); + } + public void giveHotbar(Player player) { PlayerInventory inventory = player.getInventory(); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java index e1e285ae8..41774d516 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java @@ -82,7 +82,7 @@ public class Stealth extends Skill return; } - if (!UtilTime.elapsed(Factory.Combat().Get(player).GetLastCombat(), 4000)) + if (!UtilTime.elapsed(Factory.Combat().getLog(player).GetLastCombat(), 4000)) { UtilPlayer.message(player, F.main(GetClassType().name(), "You cannot use " + F.skill(GetName()) + " while in Combat.")); return; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/ClientCombat.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/ClientCombat.java index eedee5f8c..b43d24a81 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/ClientCombat.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/ClientCombat.java @@ -1,6 +1,7 @@ package mineplex.minecraft.game.core.combat; import java.util.LinkedList; +import java.util.Map; import java.util.WeakHashMap; import mineplex.core.common.util.UtilTime; @@ -9,12 +10,12 @@ import org.bukkit.entity.LivingEntity; public class ClientCombat { - private LinkedList _kills = new LinkedList(); - private LinkedList _assists = new LinkedList(); - private LinkedList _deaths = new LinkedList(); + private final LinkedList _kills = new LinkedList<>(); + private final LinkedList _assists = new LinkedList<>(); + private final LinkedList _deaths = new LinkedList<>(); - private WeakHashMap _lastHurt = new WeakHashMap(); - private WeakHashMap _lastHurtBy = new WeakHashMap(); + private final Map _lastHurt = new WeakHashMap<>(); + private final Map _lastHurtBy = new WeakHashMap<>(); private long _lastHurtByWorld = 0; public LinkedList GetKills() diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java index 864b9e736..85d60a9be 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java @@ -5,16 +5,17 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; import mineplex.minecraft.game.core.damage.DamageChange; public class CombatLog { + private final LinkedList _damager = new LinkedList<>(); private final CombatComponent _player; private final long _expireTime; @@ -23,13 +24,13 @@ public class CombatLog private CombatComponent _killer; private int _assistants; - private String _killedColor = ChatColor.YELLOW + ""; - private String _killerColor = ChatColor.YELLOW + ""; + private String _killedColor = C.cYellow; + private String _killerColor = C.cYellow; - protected CombatComponent LastDamager; - protected long _lastDamaged; - protected long _lastCombat; - protected long _lastCombatEngaged; + private CombatComponent LastDamager; + private long _lastDamaged; + private long _lastCombat; + private long _lastCombatEngaged; public CombatLog(Player player, long expireTime) { @@ -52,6 +53,7 @@ public class CombatLog { Attacked(damagerName, damage, damagerEnt, attackName, mod, new HashMap<>()); } + public void Attacked(String damagerName, double damage, LivingEntity damagerEnt, String attackName, List mod, Map metadata) { // Add Attacked @@ -121,7 +123,9 @@ public class CombatLog for (int i = 0; i < 8; i++) { if (i < _damager.size()) - out.add(F.desc("#" + i, _damager.get(i).Display(_deathTime))); + { + out.add(F.desc("#" + (i + 1), _damager.get(i).Display(_deathTime))); + } } return out; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index 30a1529bd..f3bbbdc1c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeUnit; import net.minecraft.server.v1_8_R3.ItemStack; @@ -21,10 +22,10 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.MiniPlugin; +import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -36,11 +37,13 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.combat.event.CombatQuitEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @ReflectivelyCreateMiniPlugin -public class CombatManager extends MiniPlugin +public class CombatManager extends MiniClientPlugin { + public enum AttackReason { Attack, @@ -48,29 +51,24 @@ public class CombatManager extends MiniPlugin DefaultWeaponName } - private final Map _active = new HashMap<>(); - private final Map _combatClients = new HashMap<>(); + private static final long EXPIRE_TIME = TimeUnit.SECONDS.toMillis(15); + private final Map _active = new HashMap<>(); private final Set _removeList = new HashSet<>(); - protected long ExpireTime = 15000; - - protected AttackReason _attackReason = AttackReason.CustomWeaponName; + private AttackReason _attackReason; public CombatManager() { super("Death"); + + _attackReason = AttackReason.CustomWeaponName; } - @EventHandler - public void unload(ClientUnloadEvent event) + @Override + protected ClientCombat addPlayer(UUID uuid) { - _combatClients.remove(event.getUniqueId()); - } - - public ClientCombat Get(UUID uuid) - { - return _combatClients.computeIfAbsent(uuid, k -> new ClientCombat()); + return new ClientCombat(); } //This is a backup, for when CustomDamageEvent is disabled (manually) @@ -91,7 +89,7 @@ public class CombatManager extends MiniPlugin { if (damagerEnt instanceof Player) { - Get((Player) damagerEnt).SetLastCombat(System.currentTimeMillis()); + getLog((Player) damagerEnt).SetLastCombat(System.currentTimeMillis()); } String cause; @@ -143,7 +141,7 @@ public class CombatManager extends MiniPlugin } } - Get(damagee).Attacked(UtilEnt.getName(damagerEnt), event.getDamage(), damagerEnt, cause, null); + getLog(damagee).Attacked(UtilEnt.getName(damagerEnt), event.getDamage(), damagerEnt, cause, null); } // Damager is WORLD else @@ -151,7 +149,7 @@ public class CombatManager extends MiniPlugin DamageCause cause = event.getCause(); Pair source = getSourceAndReason(cause); - Get(damagee).Attacked(source.getLeft(), event.getDamage(), null, source.getRight(), null); + getLog(damagee).Attacked(source.getLeft(), event.getDamage(), null, source.getRight(), null); } } @@ -224,12 +222,12 @@ public class CombatManager extends MiniPlugin if (event.GetDamagerEntity(true) instanceof Player) { - Get(event.GetDamagerPlayer(true)).SetLastCombat(System.currentTimeMillis()); - Get(event.GetDamagerPlayer(true)).SetLastCombatEngaged(System.currentTimeMillis()); - Get(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis()); + getLog(event.GetDamagerPlayer(true)).SetLastCombat(System.currentTimeMillis()); + getLog(event.GetDamagerPlayer(true)).SetLastCombatEngaged(System.currentTimeMillis()); + getLog(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis()); } - Get(event.GetDamageePlayer()).Attacked(UtilEnt.getName(event.GetDamagerEntity(true)), (int) event.GetDamage(), event.GetDamagerEntity(true), reason, event.GetDamageMod(), event.getMetadata()); + getLog(event.GetDamageePlayer()).Attacked(UtilEnt.getName(event.GetDamagerEntity(true)), (int) event.GetDamage(), event.GetDamagerEntity(true), reason, event.GetDamageMod(), event.getMetadata()); } // Damager is WORLD else @@ -242,7 +240,7 @@ public class CombatManager extends MiniPlugin source.setRight(event.GetReason()); } - Get(event.GetDamageePlayer()).Attacked(source.getLeft(), (int) event.GetDamage(), null, source.getRight(), event.GetDamageMod(), event.getMetadata()); + getLog(event.GetDamageePlayer()).Attacked(source.getLeft(), (int) event.GetDamage(), null, source.getRight(), event.GetDamageMod(), event.getMetadata()); } } @@ -255,19 +253,15 @@ public class CombatManager extends MiniPlugin { case BLOCK_EXPLOSION: source = "Explosion"; - reason = "-"; break; case CONTACT: source = "Cactus"; - reason = "-"; break; case CUSTOM: source = "Custom"; - reason = "-"; break; case DROWNING: source = "Water"; - reason = "-"; break; case ENTITY_ATTACK: source = "Entity"; @@ -275,67 +269,51 @@ public class CombatManager extends MiniPlugin break; case ENTITY_EXPLOSION: source = "Explosion"; - reason = "-"; break; case FALL: source = "Fall"; - reason = "-"; break; case FALLING_BLOCK: source = "Falling Block"; - reason = "-"; break; case FIRE: source = "Fire"; - reason = "-"; break; case FIRE_TICK: source = "Fire"; - reason = "-"; break; case LAVA: source = "Lava"; - reason = "-"; break; case LIGHTNING: source = "Lightning"; - reason = "-"; break; case MAGIC: source = "Magic"; - reason = "-"; break; case MELTING: source = "Melting"; - reason = "-"; break; case POISON: source = "Poison"; - reason = "-"; break; case PROJECTILE: source = "Projectile"; - reason = "-"; break; case STARVATION: source = "Starvation"; - reason = "-"; break; case SUFFOCATION: source = "Suffocation"; - reason = "-"; break; case SUICIDE: source = "Suicide"; - reason = "-"; break; case VOID: source = "Void"; - reason = "-"; break; case WITHER: source = "Wither"; - reason = "-"; break; } @@ -343,7 +321,31 @@ public class CombatManager extends MiniPlugin } @EventHandler(priority = EventPriority.LOW) - public void HandleDeath(PlayerDeathEvent event) + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + CombatLog log = _active.get(player.getUniqueId()); + + if (log == null || log.GetAttackers().isEmpty()) + { + return; + } + + CombatQuitEvent combatQuitEvent = new CombatQuitEvent(player); + // Cancelled by default + combatQuitEvent.setCancelled(true); + UtilServer.CallEvent(combatQuitEvent); + + if (combatQuitEvent.isCancelled()) + { + return; + } + + playerDeath(new PlayerDeathEvent(player, null, 0, null)); + } + + @EventHandler(priority = EventPriority.LOW) + public void playerDeath(PlayerDeathEvent event) { event.setDeathMessage(null); @@ -497,9 +499,9 @@ public class CombatManager extends MiniPlugin } } - public CombatLog Get(Player player) + public CombatLog getLog(Player player) { - return _active.computeIfAbsent(player.getUniqueId(), k -> new CombatLog(player, ExpireTime)); + return _active.computeIfAbsent(player.getUniqueId(), k -> new CombatLog(player, EXPIRE_TIME)); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/event/CombatQuitEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/event/CombatQuitEvent.java new file mode 100644 index 000000000..1d1172acd --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/event/CombatQuitEvent.java @@ -0,0 +1,42 @@ +package mineplex.minecraft.game.core.combat.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class CombatQuitEvent extends PlayerEvent implements Cancellable +{ + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + public static HandlerList getHandlerList() + { + return HANDLER_LIST; + } + + private boolean _cancelled; + + public CombatQuitEvent(Player who) + { + super(who); + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public HandlerList getHandlers() + { + return HANDLER_LIST; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index 887abc5b8..bd103cdf9 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -274,27 +274,6 @@ public class DamageManager extends MiniPlugin projectile.remove(); } } - /* - private boolean GoldPower(LivingEntity damager) - { - try - { - Player player = (Player)damager; - if (!Util().Gear().isGold(player.getItemInHand())) - return false; - - if (!player.getInventory().contains(Material.GOLD_NUGGET)) - return false; - - UtilInv.remove(player, Material.GOLD_NUGGET, (byte)0, 1); - return true; - } - catch (Exception e) - { - return false; - } - } - */ public CustomDamageEvent NewDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile proj, DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 623be03b4..8968ffb64 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -125,6 +125,7 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; import mineplex.minecraft.game.core.IRelation; +import mineplex.minecraft.game.core.combat.event.CombatQuitEvent; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -137,6 +138,7 @@ import nautilus.game.arcade.command.CancelNextGameCommand; import nautilus.game.arcade.command.GameCommand; import nautilus.game.arcade.command.GoToNextGameCommand; import nautilus.game.arcade.command.KitUnlockCommand; +import nautilus.game.arcade.command.MapCommand; import nautilus.game.arcade.command.ReturnToHubCommand; import nautilus.game.arcade.command.SpectatorCommand; import nautilus.game.arcade.command.TauntCommand; @@ -188,7 +190,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation BYPASS_MPS_WHITELIST, RETURN_TO_HUB_COMMAND, TOURNAMENT_STOP_COMMAND, - SPECTATOR_COMMAND + SPECTATOR_COMMAND, + MAP_COMMAND } // Modules @@ -664,6 +667,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation PermissionGroup.MOD.setPermission(Perm.BYPASS_MPS_WHITELIST, true, true); PermissionGroup.EVENTMOD.setPermission(Perm.TOURNAMENT_STOP_COMMAND, false, true); PermissionGroup.PLAYER.setPermission(Perm.SPECTATOR_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.MAP_COMMAND, true, true); } @Override @@ -671,6 +675,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { addCommand(new GameCommand(this)); addCommand(new KitUnlockCommand(this)); + addCommand(new MapCommand(this)); } public GameChatManager getGameChatManager() @@ -1565,11 +1570,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _serverConfig.PlayerKickIdle; } - public int GetDesiredPlayerAmount() - { - return _serverConfig.MaxPlayers; - } - public String GetHost() { return _serverConfig.HostName; @@ -1637,7 +1637,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation } else if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Loading || event.GetState() == GameState.Dead) { - if (event.GetGame().GadgetsDisabled) + Game game = event.GetGame(); + + if (game.GadgetsDisabled) { if (getCosmeticManager().isShowingInterface()) { @@ -1646,12 +1648,36 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } - if (!event.GetGame().AllowParticles) + if (game.AllowParticles) + { + for (Player player : UtilServer.getPlayersCollection()) + { + Gadget gadget = getCosmeticManager().getGadgetManager().getActive(player, GadgetType.PARTICLE); + + if (gadget == null || isVanished(player)) + { + continue; + } + + if (getPreferences().get(player).isActive(Preference.PARTICLES_IN_GAME)) + { + if (!gadget.isActive(player)) + { + gadget.enable(player, false); + } + } + else + { + gadget.disable(player, false); + } + } + } + else { getCosmeticManager().setHideParticles(true); } - if (event.GetGame().ShowWeaponNames) + if (game.ShowWeaponNames) { getCosmeticManager().getGadgetManager().setShowWeaponNames(true); } @@ -1695,54 +1721,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } - /*public void saveBasicStats(final Game game) - { - if (!IsTournamentServer()) - return; - - final Map data = new HashMap<>(); - - for (Player loser : game.getLosers()) - data.put(loser.getUniqueId(), false); - - for (Player winner : game.getWinners()) - data.put(winner.getUniqueId(), true); - - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - @Override - public void run() - { - getArcadeRepository().saveBasicStats(game.GetType(), IsTournamentServer(), (int) (System.currentTimeMillis() - game.getGameLiveTime()), data); - } - }); - }*/ - - /*public void saveLeaderboardStats(Game game) - { - final TournamentType type = TournamentType.getTournamentType(game.GetType()); - - if (type != null) - { - final Map data = new HashMap<>(); - - for (Player loser : game.getLosers()) - data.put(loser.getUniqueId(), false); - - for (Player winner : game.getWinners()) - data.put(winner.getUniqueId(), true); - - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - @Override - public void run() - { - getArcadeRepository().saveLeaderboardStats(0, type.ordinal(), data); - } - }); - } - }*/ - public boolean isGameInProgress() { return _game != null && _game.InProgress(); @@ -1763,11 +1741,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _preferencesManager.save(preferences); } - public IdleManager getIdleManager() - { - return _idleManager; - } - public void enableChampionsModules() { _classManager.setEnabled(true); @@ -1854,9 +1827,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public boolean isSpectator(Entity player) { - if (player instanceof Player) - return UtilPlayer.isSpectator(player); - return false; + return UtilPlayer.isSpectator(player); } @EventHandler(priority = EventPriority.LOWEST) @@ -2018,6 +1989,17 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } + @EventHandler + public void combatQuit(CombatQuitEvent event) + { + if (_game == null || !_game.IsLive()) + { + return; + } + + event.setCancelled(false); + } + public List getValidPlayersForGameStart() { return PlayerSelector.selectPlayers( diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/MapCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/MapCommand.java new file mode 100644 index 000000000..9867982df --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/MapCommand.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.ArcadeManager.Perm; +import nautilus.game.arcade.game.Game; + +public class MapCommand extends CommandBase +{ + + public MapCommand(ArcadeManager plugin) + { + super(plugin, Perm.MAP_COMMAND, "map", "whatmap"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Game game = Plugin.GetGame(); + + if (game == null || game.WorldData == null) + { + caller.sendMessage(F.main(Plugin.getName(), "Is this the work of an enemy stand? There's no map?")); + return; + } + + caller.sendMessage(F.main(Plugin.getName(), game.WorldData.getFormattedName())); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java index 8cf8de13d..65bdc84b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java @@ -33,7 +33,7 @@ public class TauntCommand extends CommandBase gameDisplay = game.GetType().getDisplay(); } TauntCommandEvent event = new TauntCommandEvent(player, _arcadeManager.isGameInProgress(), - _arcadeManager.GetGame().IsAlive(player), UtilPlayer.isSpectator(player), combatManager.Get(player).GetLastCombatEngaged(), + _arcadeManager.GetGame().IsAlive(player), UtilPlayer.isSpectator(player), combatManager.getLog(player).GetLastCombatEngaged(), gameDisplay); Bukkit.getPluginManager().callEvent(event); } 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 e54d90276..45e84931d 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 @@ -186,7 +186,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed // Player Data private NautHashMap> _gemCount = new NautHashMap>(); - private NautHashMap> _stats = new NautHashMap>(); + private final Map> _stats = new HashMap<>(); private NautHashMap _playerInTime = new NautHashMap<>(); // Player Location Store @@ -1364,7 +1364,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, C.cGreen + "Game - " + C.cYellow + C.Bold + this.GetName()); + UtilPlayer.message(player, C.cGreen + "Game - " + C.cWhiteB + GetName()); UtilPlayer.message(player, ""); for (String line : this.GetDesc()) @@ -1373,8 +1373,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed } UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray - + " created by " + C.cYellow + C.Bold + WorldData.MapAuthor); + UtilPlayer.message(player, WorldData.getFormattedName()); UtilPlayer.message(player, ArcadeFormat.Line); } @@ -1469,8 +1468,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed } UtilPlayer.message(player, ""); - UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" - + WorldData.MapAuthor); + UtilPlayer.message(player, WorldData.getFormattedName()); UtilPlayer.message(player, ArcadeFormat.Line); } @@ -1542,8 +1540,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed } UtilPlayer.message(player, ""); - UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" - + WorldData.MapAuthor); + UtilPlayer.message(player, WorldData.getFormattedName()); UtilPlayer.message(player, ArcadeFormat.Line); } @@ -1679,7 +1676,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public abstract List getLosers(); - public NautHashMap> GetStats() + public Map> GetStats() { return _stats; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java index a036f53d1..068b547b5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java @@ -8,6 +8,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.bukkit.Color; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -282,9 +283,13 @@ public class CakeTeamModule extends CakeModule _samePlayer = false; } + Location location = block.getLocation(); + + block.getWorld().playEffect(location, Effect.STEP_SOUND, Material.CAKE); + if (data < 6) { - block.getWorld().playSound(block.getLocation(), Sound.EAT, 1, 1); + block.getWorld().playSound(location, Sound.EAT, 1, 1); block.setData((byte) (data + 1)); } else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index 8ba1b2842..b01af9840 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -1,6 +1,6 @@ package nautilus.game.arcade.game.games.minestrike.items.guns; -import java.util.HashMap; +import java.util.Map; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -345,7 +345,7 @@ public class Gun extends StrikeItem Player owner = UtilPlayer.searchExact(getOwnerName()); if (owner != null) { - HashMap localStatsMap = game.getHost().GetStats().get(owner); + Map localStatsMap = game.getHost().GetStats().get(owner); if (localStatsMap != null) { Integer kills = localStatsMap.get(game.getHost().GetName() + "." + getStatNameKills(true)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java index fa0d08c1c..b0607a6fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.wizards.spells; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -61,7 +60,7 @@ public class SpellGust extends Spell implements SpellClick Wizards.getArcadeManager().GetCondition().Factory().Falling("Gust", target, player, 40, false, true); - Wizards.Manager.GetDamage().GetCombatManager().Get(target).Attacked(player.getName(), 0, player, "Gust", new ArrayList()); + Wizards.Manager.GetDamage().GetCombatManager().getLog(target).Attacked(player.getName(), 0, player, "Gust", new ArrayList()); UtilAction.velocity(target, vec); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index 503dee281..bf66b3784 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.managers; import java.util.HashMap; +import java.util.Map; import java.util.UUID; import org.bukkit.entity.Player; @@ -8,19 +9,16 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.stats.StatTracker; @@ -31,68 +29,91 @@ public class GameStatManager implements Listener STAT_BOOST_COMMAND, } - ArcadeManager Manager; + final ArcadeManager Manager; - private final HashMap _joinTimes = new HashMap<>(); + private final Map _joinTimes = new HashMap<>(); public GameStatManager(ArcadeManager manager) { Manager = manager; - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + Manager.registerEvents(this); generatePermissions(); } private void generatePermissions() { - PermissionGroup.LT.setPermission(Perm.STAT_BOOST_COMMAND, true, true); } @EventHandler - public void StatEnableDisable(GameStateChangeEvent event) + public void statEnableDisable(GameStateChangeEvent event) { - if (!Manager.IsRewardStats()) + if (!Manager.IsRewardStats() || event.GetState() != GameState.Live) + { return; - - if (event.GetState() != GameState.Live) - return; - - //int requirement = (int)((double)event.GetGame().Manager.GetPlayerFull() * 0.75d); + } + int requirement = 2; - - event.GetGame().CanAddStats = (double)event.GetGame().GetPlayers(true).size() >= requirement; - + + event.GetGame().CanAddStats = event.GetGame().GetPlayers(true).size() >= requirement; + if (!event.GetGame().CanAddStats) + { event.GetGame().Announce(C.Bold + "Stats/Achievements Disabled. Requires " + requirement + " Players.", event.GetGame().PlaySoundGameStart); + } } @EventHandler - public void StatRegister(GameStateChangeEvent event) + public void statRecord(GameStateChangeEvent event) { - if (!Manager.IsRewardStats()) - return; - - if (event.GetState() != GameState.Dead) - return; - - for (Player player : event.GetGame().GetStats().keySet()) + if (!Manager.IsRewardStats() || event.GetState() != GameState.Dead) { - for (String stat : event.GetGame().GetStats().get(player).keySet()) + return; + } + + event.GetGame().GetStats().forEach((player, statMap) -> + { + statMap.forEach((stat, value) -> + { + if (value > 0) + { + Manager.GetStatsManager().incrementStat(player, stat, value); + } + }); + }); + } + + @EventHandler(priority = EventPriority.HIGH) + public void statRecord(PlayerQuitEvent event) + { + Game game = Manager.GetGame(); + + if (game == null || !game.IsLive()) + { + return; + } + + Player player = event.getPlayer(); + Map stats = game.GetStats().remove(player); + + if (stats == null) + { + return; + } + + stats.forEach((stat, value) -> + { + if (value > 0) { - int value = event.GetGame().GetStats().get(player).get(stat); - - if (value <= 0) - continue; - Manager.GetStatsManager().incrementStat(player, stat, value); } - } + }); } @EventHandler - public void StatGameRecord(GameStateChangeEvent event) + public void statTrackCleanup(GameStateChangeEvent event) { if (event.GetState() == GameState.End) { @@ -121,35 +142,4 @@ public class GameStatManager implements Listener Manager.GetStatsManager().incrementStat(event.getPlayer(), "Global.TimeInGame", timeInGame); } } - - @EventHandler - public void statBoostCommand(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.STAT_BOOST_COMMAND)) - { - event.setCancelled(true); - - String[] tokens = event.getMessage().split(" "); - - if (tokens.length < 2) - return; - - Player player = UtilPlayer.searchOnline(event.getPlayer(), tokens[1], true); - if (player == null) - return; - - for (GameType type : GameType.values()) - { - int wins = UtilMath.r(50); - int loss = UtilMath.r(50); - int play = wins+loss; - - Manager.GetStatsManager().incrementStat(player, type.getName() + ".Wins", wins); - Manager.GetStatsManager().incrementStat(player, type.getName() + ".Losses", loss); - Manager.GetStatsManager().incrementStat(player, type.getName() + ".GamesPlayed", play); - } - - event.getPlayer().sendMessage("Gave Stats: " + player.getName()); - } - } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java index 364d43cd5..079fd4ba1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -14,15 +15,16 @@ import org.bukkit.event.world.ChunkUnloadEvent; public class GameWorldManager implements Listener { - ArcadeManager Manager; + + final ArcadeManager Manager; - private HashSet _worldLoader = new HashSet(); + private final Set _worldLoader = new HashSet<>(); public GameWorldManager(ArcadeManager manager) { Manager = manager; - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + Manager.registerEvents(this); } @EventHandler @@ -54,16 +56,6 @@ public class GameWorldManager implements Listener } } - /* - @EventHandler - public void ChunkLoad(ChunkPreLoadEvent event) - { - if (Manager.GetGame() != null) - if (Manager.GetGame().WorldData != null) - Manager.GetGame().WorldData.ChunkLoad(event); - } - */ - @EventHandler public void ChunkUnload(ChunkUnloadEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java index 739a4e618..5c6ee189f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java @@ -1,39 +1,27 @@ package nautilus.game.arcade.stats; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; + import nautilus.game.arcade.game.Game; public class DeathsStatTracker extends StatTracker { + public DeathsStatTracker(Game game) { super(game); } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) + if (!getGame().IsLive()) + { return; + } - if (event.GetLog().GetPlayer() == null) - return; - - if (!event.GetLog().GetPlayer().IsPlayer()) - return; - - Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) - return; - - addStat(player, "Deaths", 1, false, false); - -// if (getGame().GetKit(player) != null) -// addStat(player, getGame().GetKit(player).getName() + " Deaths", 1, false, false); + addStat(event.GetEvent().getEntity(), "Deaths", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 8d1de7693..4c93332f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -20,6 +20,7 @@ import org.spigotmc.SpigotConfig; import mineplex.core.common.Pair; import mineplex.core.common.api.enderchest.EnderchestWorldLoader; import mineplex.core.common.timing.TimingManager; +import mineplex.core.common.util.C; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilMath; @@ -490,4 +491,8 @@ public class WorldData return _dataEntries.get(key); } + public String getFormattedName() + { + return C.cGreen + "Map - " + C.cWhiteB + MapName + C.cGray + " created by " + C.cWhiteB + MapAuthor; + } }